Base solution for your next web application

Activities of "hasan"

Dear Team I am just starting this wonderful module for one of my project

How to give authorization generated to API Controllers ?

For example,

before the user calls, he has to login and get the session id before he proceeds to call other methods

Would like to achieve something like this ?

<a class="postlink" href="http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api">http://www.asp.net/web-api/overview/sec ... in-web-api</a>

Dear Hikalkan

Thanks for your reply.

For my case, I will have to create a API Controller by myself and use the APIauthorize attribute

Please clarify

Hello Team

It could be very basic question but i have stuck with this

I have an Entity Structure like this one below

public class OrderTagGroup : Entity
    {
        public virtual string Name { get; set; }
        public virtual List<OrderTag> OrderTags { get; set; }
    }

     public class OrderTag : Entity
    {
        public virtual string Name { get; set; }
        public virtual int? OrderTagGroupId { get; set; }
    }

and Its respective DTO is

public class OrderTagGroupDto : EntityDto
{
    [Required]
    public string Name { get; set; }


    public List<OrderTagDto> OrderTags { get; set; }
}

public class OrderTagDto : EntityDto
{
    [Required]
    public string Name { get; set; }


    public int? OrderTagGroupId { get; set; }
}

I have added the Auto mapping as well like this

Mapper.CreateMap<OrderTagGroup, OrderTagGroupDto>();
            Mapper.CreateMap<OrderTagGroupDto, OrderTagGroup>();

            Mapper.CreateMap<OrderTag, OrderTagDto>();
            Mapper.CreateMap<OrderTagDto, OrderTag>();

Here is my Repository update

public void UpdateOrderTagGroup(OrderTagGroupDto OrderTagGroup)
        {
            var group = _OrderTagGroupRepo.Get(OrderTagGroup.Id);
            if (group != null && group.Id > 0)
            {
                Mapper.Map<OrderTagGroupDto, OrderTagGroup>(OrderTagGroup,group);
              
            }
        }

My Question is, whenever my OrderTagGroupDTO goes for the update, it creates a new row in the DB and previous entry is not deleted.

Could you please help me where i am wrong ?

Thank you so much for the reply

Do we have any sample code in any of the Repository ?

It would be really helpful

Hello Team

There are three questions here..

  1. In the commercial project, do we have a sample of Morris Chart data comes from controller ?. If you do not have, is it possible to put up some example ?

  2. I am unable see the Tenent Settings for the default admin user ?. How to get it enabled ? What is difference between Tenent, Host and Common folder and why we need to put Views in the Tenent Folder ?

  3. How to enable the auto migration for Entity Framework ?. If not, whenever I deploy to my customer server (Azure Website or Cloud) how can I run the migration automatically ?

Thanks

Question

Hello Sir

Instead of jQuery UI Theme, I would like to do a Bootstrap for jTable.

Please help me to show a link or an example.

Thanks

Hello Hikalan,

Thanks for the answer

Is it possible to give a Morris Chart Example ?

I have tried like below but it is not getting refreshed

Morris.Donut({
            element: 'payment_stats',
            data: [
              { label: "Download Sales", value: 12 },
              { label: "In-Store Sales", value: 30 },
              { label: "Mail-Order Sales", value: 20 }
            ]
        });

        Morris.Donut({
            element: 'transaction_stats',
            data: _ticketService.getTransactionStats()
        });

The first Morris is coming into the Screen but the second one is not coming. My Service is this like below

public MorrisOutputDto GetTransactionStats()
        {
            
            List<MorrisListDto> outputDtos = new List<MorrisListDto>();

            outputDtos.Add(new MorrisListDto()
            {
                Label = "SALES",
                Value = 190
            });
            outputDtos.Add(new MorrisListDto()
            {
                Label = "PURCHASE",
                Value = 190
            });
            outputDtos.Add(new MorrisListDto()
            {
                Label = "NETS",
                Value = 190
            });
            MorrisOutputDto outputDto = new MorrisOutputDto(outputDtos);

            return outputDto;
        }

Please correct me where i am wrong

Thanks mate

Hello Sir

I have done that perfectly. Here is the code for that

function payment_chart() {
            abp.ajax({
                url: '/Dashboard/paymentChart'
            }).done(function (data) {
                Morris.Donut({
                    element: 'payment_stats',
                    data: $.parseJSON(JSON.stringify(data)),
                    resize: true
                });
            });
            return JSON.stringify("");
        }

        payment_chart();
Question

Hello Sir

I would like you to help on WEB API.

I was trying to get the Users from the link below [http://aspnetzero.com/Documents/Development-Guide#token-based-authentication])

but i am getting following error

{
  "success": false,
  "result": null,
  "error": {
    "code": 0,
    "message": "No user logged in!",
    "details": null,
    "validationErrors": null
  },
  "unAuthorizedRequest": true
}

I have already authenticated users in your previous steps and copied that authorization as well

I have added three attachments for your perusal as well.

Thanks

Hello Sir,

I am building a Master Child Table but it seems like it throws the error at the Javascript at ABP.

Here is my code and let me know if there is any bug in the ABP

My JavaScript as

(function () {
    $(function () {

        var _$jsTable = $('#TicketTable');
        var _appService = abp.services.app.ticket;
        var _$filterForm = $('#TicketForm');

        var _todayAsString = moment().format('YYYY-MM-DD');

        var _selectedDateRange = {
            startDate: _todayAsString,
            endDate: _todayAsString
        };

        _$filterForm.find('input.date-range-picker').daterangepicker(
            $.extend(true, app.createDateRangePickerOptions(), _selectedDateRange),
            function (start, end, label) {
                _selectedDateRange.startDate = start.format('YYYY-MM-DD');
                _selectedDateRange.endDate = end.format('YYYY-MM-DD');
            });

        _$jsTable.jtable({
            paging: true,
            sorting: true,
            pageSize: 20,
            multiSorting: true,
            title: app.localize('Tickets'),

            actions: {
                listAction: {
                    method: _appService.getTickets
                }
            },

            fields: {
                id: {
                    key: true,
                    list: false
                },
                payments: {
                    title: '',
                    width: '5%',
                    sorting: false,
                    display: function (paymentData) {
                        var $img = $('<span>Payments</span>');
                        $img.click(function () {
                            $('#TicketTable').jtable('openChildTable',
                                    $img.closest('tr'),
                                    {
                                        title: 'PAYMENTS FOR TICKET  : ' + paymentData.record.ticketNumber,
                                        actions: {
                                            listAction: {
                                                method: _appService.getPaymentForTicketId(paymentData.record.id)
                                            }
                                        },
                                        fields: {
                                            Id: {
                                                key: true,
                                                list: false
                                            },
                                            Amount: {
                                                title: app.localize('TotalAmount'),
                                                width: '25%',
                                                display: function (data) {
                                                    var $span = $('<span></span>');
                                                    $span.append(data.record.Amount + " &nbsp; ");
                                                    return $span;
                                                }
                                            }
                                        }
                                    }, function (data) { //opened handler
                                        data.childTable.jtable('load');
                                    });
                        });
                        //Return image to show on the person row
                        return $img;
                    }
                },
                ticketNumber: {
                    title: app.localize('TicketNumber'),
                    width: '25%',
                    display: function (data) {
                        var $span = $('<span></span>');
                        $span.append(data.record.ticketNumber + " &nbsp; ");
                        return $span;
                    }
                },
                totalAmount: {
                    title: app.localize('TotalAmount'),
                    width: '25%',
                    display: function (data) {
                        var $span = $('<span></span>');
                        $span.append(data.record.totalAmount + " &nbsp; ");
                        return $span;
                    }
                }
            }

        });

        function createRequestParams() {
            var prms = {};
            _$filterForm.serializeArray().map(function (x) { prms[x.name] = x.value; });
            return $.extend(prms, _selectedDateRange);
        }


        $('#ExportExcel').click(function () {
            _appService
                .getItemsToExcel({})
                .done(function (result) {
                    app.downloadTempFile(result);
                });
        });
       
        $('#GetItems').click(function (e) {
            e.preventDefault();
            getItems();
        });

        function getItems(reload) {
            if (reload) {
                _$jsTable.jtable('reload');
            } else {
                _$jsTable.jtable('load', {
                    filter: $('#InputFilter').val()
                });
            }
        }
        getItems();

        $('#RefreshAuditLogsButton').click(function (e) {
            e.preventDefault();
            getAuditLogs();
        });

        $('#ExportAuditLogsToExcelButton').click(function (e) {
            e.preventDefault();
            _appService.getAuditLogsToExcel(createRequestParams())
                .done(function (result) {
                    app.downloadTempFile(result);
                });
        });

        $('#ShowAdvancedFiltersSpan').click(function () {
            $('#ShowAdvancedFiltersSpan').hide();
            $('#HideAdvancedFiltersSpan').show();
            $('#AdvacedAuditFiltersArea').slideDown();
        });

        $('#HideAdvancedFiltersSpan').click(function () {
            $('#HideAdvancedFiltersSpan').hide();
            $('#ShowAdvancedFiltersSpan').show();
            $('#AdvacedAuditFiltersArea').slideUp();
        });

        _$filterForm.keydown(function (e) {
            if (e.which == 13) {
                e.preventDefault();
                getAuditLogs();
            }
        });
    });
})();

My Service as below

public async Task<PagedResultOutput<PaymentListDto>>  GetPaymentForTicketId(int ticketId)
        {
            var output = _paRepository.GetAll().Where(a => a.TicketId.Equals(ticketId));
            var categoryListDtos = output.MapTo<List<PaymentListDto>>();

            var menuItemCount = await output.CountAsync();

            return new PagedResultOutput<PaymentListDto>(
                menuItemCount,
                categoryListDtos
                );

        }
      public async Task<PagedResultOutput<TicketListDto>> GetTickets(GetTicketInput input)
        {
            var tickets = _ticketManager
                .GetAll()
                .WhereIf(
                    !input.Filter.IsNullOrEmpty(),
                    p => p.Restaurant.Name.Contains(input.Filter)
                );

            var sortTickets = await tickets
                .OrderBy(input.Sorting)
                .PageBy(input)
                .ToListAsync();

            var categoryListDtos = sortTickets.MapTo<List<TicketListDto>>();
            var menuItemCount = await tickets.CountAsync();

            return new PagedResultOutput<TicketListDto>(
                menuItemCount,
                categoryListDtos
                );
        }

The error is attached as a image below

Showing 1 to 10 of 97 entries