コード例 #1
0
        public async Task <List <FormItemModel> > GetList()
        {
            if (await _authorizationService.AuthorizeAsync(Policies.ReviewerPolicy))
            {
                return(await _service.GetCustomerForms <FormItemModel>());
            }
            CustomerItemModel?customer = await _customerService.GetCurrentCustomer <CustomerItemModel>();

            if (customer == null)
            {
                return(new List <FormItemModel>());
            }
            return(await _service.GetCustomerForms <FormItemModel>(customer.Id));
        }
コード例 #2
0
        public async Task <CustomerDetailModel?> Get(int id)
        {
            CustomerDetailModel?model = await GetCustomerDetailModel(id);

            if (model != null)
            {
                bool isAdmin = await _authorization.AuthorizeAsync(Policies.AdminPolicy);

                model.SubscriptionConfiguration.NotificationConfigurations = await _notificationService.GetConfigurationList <NotificationConfigurationItemModel>(isAdmin?NotificationTarget.Admin : NotificationTarget.Customer);

                return(model);
            }
            //bad request return no customer profile
            return(null);
        }
コード例 #3
0
        public async Task <PendingTaskListModel> GetPendingTasks()
        {
            bool isReviewer = await _authorization.AuthorizeAsync(Policies.ReviewerPolicy);

            PendingTaskListModel model = new PendingTaskListModel();

            if (isReviewer)
            {
                List <FormItemModel> forms = await _formService.GetCustomerForms <FormItemModel>(CustomerFormStatus.AwaitingAdminApproval);

                forms.ForEach(x => {
                    model.AddTask(x.CustomerDetailFormId, PendingTaskType.FormAdminApproval, $"{x.CustomerName} has a pending MTA form awaiting admin approval");
                });

                List <OrderItemModel> orders = await _orderService.GetList <OrderItemModel>(OrderStatus.Sent);

                orders.ForEach(x => {
                    model.AddTask(x.Id, PendingTaskType.OrderAdminApproval, $"{x.Customer.Contact.FirstName} {x.Customer.Contact.LastName} has a pending order awaiting admin approval");
                });

                List <ShipmentItemModel> shipments = await _shipmentService.GetList <ShipmentItemModel>(ShipmentStatus.Created);

                shipments.ForEach(x => {
                    model.AddTask(x.Id, PendingTaskType.ShippingAdminApproval, $"{x.Customer.Contact.FirstName} {x.Customer.Contact.LastName} has a pending shipment awaiting processing");
                });
            }

            List <OrderItemModel> ordersAwaitingCustomerApproval = await _orderService.GetList <OrderItemModel>(OrderStatus.AwaitingCustomerApproval);

            ordersAwaitingCustomerApproval.ForEach(x => {
                model.AddTask(x.Id, PendingTaskType.OrderCustomerApproval, $"Order {x.Id} has been amended and is awaiting your approval");
            });
            return(model);
        }
コード例 #4
0
        public async Task <IActionResult> Create()
        {
            if (await _authorizationService.AuthorizeAsync(Policies.AdminPolicy))
            {
                return(View(null));
            }
            CustomerItemModel?customer = await _customerManager.GetCurrentCustomer();

            if (customer == null)
            {
                return(NotFound());
            }
            return(View(await _orderManager.GetOrderForm(customer)));
        }
コード例 #5
0
        public async Task <OrderDetailModel?> Get(int id)
        {
            bool isReviewer = await _authorizationService.AuthorizeAsync(Policies.ReviewerPolicy);

            if (isReviewer)
            {
                return(await _service.Get <OrderDetailModel>(id));
            }
            CustomerItemModel?customer = await _customerService.GetCurrentCustomer <CustomerItemModel>();

            if (customer == null)
            {
                return(null);
            }
            return(await _service.Get <OrderDetailModel>(id, customer.Id, customer.ParentCustomerId));
        }