Exemple #1
0
        public async Task <ActionResult> List(Paging paging, List <OrderBy> orderBy)
        {
            try
            {
                var data = await _sellerBusinessService.RetrieveSellers(orderBy, paging);

                return(this.JsonNet(data));
            }
            catch (Exception ex)
            {
                return(this.JsonNet(""));;
            }
        }
        public async Task <ValidationResult <Order> > CreateOrder(int mobileId, int personnelId, List <int> sellerIds, int shippingAddressId)
        {
            ValidationResult <Order> validationResult = new ValidationResult <Order>();

            try
            {
                var order = new Order()
                {
                    CreatedDateTime   = DateTime.Now,
                    MobileId          = mobileId,
                    OrderGuid         = Guid.NewGuid(),
                    OrderStateId      = (int)OrderState.Requested,
                    PersonnelId       = personnelId,
                    ShippingAddressId = shippingAddressId
                };
                var orderEntity = await _dataService.CreateGetAsync(order);

                var sellerOrderList = sellerIds.Select(seller => new SellerOrder()
                {
                    OrderId  = orderEntity.OrderId,
                    SellerId = seller
                }).ToList();
                await _dataService.CreateRangeAsync(sellerOrderList);

                var customerPersonnel = await _personnelDataService.RetrieveByIdAsync <Personnel>(personnelId);

                var sellers = await _sellerBusinessService.RetrieveSellers(sellerIds);

                //var personnelData = await _personnelDataService.RetrieveByIdAsync<Personnel>(mobileId.PersonnelId);
                var mobileData = await _mobileDataService.RetrieveByIdAsync <Entity.Mobile>(mobileId);
                await SendOrderEmailToCustomer(orderEntity, customerPersonnel, mobileData);
                await SendOrderEmailToSellers(orderEntity, sellers, customerPersonnel, mobileData);

                SendOrderSms(order, sellers, customerPersonnel, mobileData);
                validationResult.Succeeded = true;
            }
            catch (Exception ex)
            {
                validationResult.Succeeded = false;
                validationResult.Errors    = new List <string> {
                    ex.InnerMessage()
                };
                validationResult.Exception = ex;
            }
            return(validationResult);
        }