コード例 #1
0
        public async Task UpdateOrderStatusAsync(OrderStatusViewModel input)
        {
            var order = this.orders.All().FirstOrDefault(o => o.Id == input.Id);

            foreach (var orderToInput in input.OrderTos)
            {
                var orderTo = order.OrderTos.FirstOrDefault(ot => ot.Id == orderToInput.Id);
                foreach (var actionInput in orderToInput.OrderStatusActions)
                {
                    var action = orderTo.OrderActions.FirstOrDefault(oa => oa.Id == actionInput.Id);
                    action.NotFinishedReasonId = actionInput.NotFinishedReasonId == 0 ? null : actionInput.NotFinishedReasonId;
                    action.NoNotes             = actionInput.NoNotes;
                    action.Notes = actionInput.Notes;
                    if (action.NoNotes || !string.IsNullOrWhiteSpace(actionInput.Notes))
                    {
                        action.IsFinished = true;
                    }

                    this.orderActions.Update(action);
                }
            }

            if (order.OrderTos.All(oa => oa.IsFinished))
            {
                order.Status = this.orderStatuses.AllAsNoTracking()
                               .FirstOrDefault(s => s.Name == OrderStatusNames.Finished.ToString());
            }

            await this.orderTos.SaveChangesAsync();
        }
コード例 #2
0
        // GET: OrderStatus
        public ActionResult OrderList()
        {
            if (Session["Customer"] == null)
            {
                return(Redirect("/CustomerLogin/CustomerLoginIndex"));
            }
            using (var db = new ModelContext())
            {
                var osList = new List <List <OrderStatusViewModel> >();

                int ctmId       = int.Parse(Session["Customer"].ToString());
                var orderNoList = (from odn in db.Orders
                                   where odn.CustomerId == ctmId
                                   select new { odn.OrderNo }).ToList();

                for (int i = 0; i < orderNoList.Count(); i++)
                {
                    int odn             = orderNoList[i].OrderNo;
                    var orderDetailList = (from e in db.OrderDetails
                                           where e.OrderNo == odn
                                           select e).ToList();

                    var osvmList = new List <OrderStatusViewModel>();
                    for (int j = 0; j < orderDetailList.Count(); j++)
                    {
                        var osvm = new OrderStatusViewModel(orderDetailList[j]);
                        osvmList.Add(osvm);
                    }
                    osList.Add(osvmList);
                }

                return(View(osList));
            }
        }
コード例 #3
0
        public async Task <IActionResult> FinishOrderTo(string orderToId, OrderStatusViewModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.RedirectToAction("Status", this.ordersService.LoadOrderStatusModel(input.Id)));
            }

            await this.ordersService.UpdateOrderStatusAsync(input);

            // if (this.orders.All().FirstOrDefault(o => o.Id == input.Id).OrderTos
            //                      .SelectMany(o => o.OrderActions)
            //                      .Any(a => !a.IsFinished))
            // {
            //     this.ModelState.AddModelError(string.Empty, "All actions must be completed to finish order.");
            //     return this.RedirectToAction("Status", this.ordersService.LoadOrderStatusModel(input.Id));
            // }
            try
            {
                await this.ordersService.FinishOrderToAsync(orderToId);
            }
            catch (Exception ex)
            {
                this.notyfService.Error(ex.Message);
            }

            await this.ordersService.UpdateOrderStatusAsync(input);

            return(this.Redirect(@$ "/Orders/Status/{input.Id}"));
        }
コード例 #4
0
        /// <summary>
        /// Получает содержимое страницы.
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var model = new OrderStatusViewModel();

            model.OrderStatusesGrid            = new DataGridDescriptor();
            model.OrderStatusesGrid.Name       = ControllerName;
            model.OrderStatusesGrid.Controller = ControllerName;
            model.OrderStatusesGrid.SearchInputs.Add(new TextSearchInput {
                Id = "Name", Value = string.Empty, Name = "Название"
            });

            model.OrderStatusesGrid.Columns.Add(new TextGridColumn {
                Name = "Название", Id = "Title"
            });
            model.OrderStatusesGrid.DeleteButtonGridColumn = new DeleteButtonGridColumn {
                QuestionText = "Вы точно хотите удалить тип ", DataId = "Title"
            };

            model.OrderStatusesGrid.EditButtonGridColumn = new EditButtonGridColumn {
                Height = 300, Width = 300
            };
            model.OrderStatusesGrid.CreateButtonGrid = new CreateButtonGrid {
                Name = "Создание типа", Height = 300, Width = 300
            };

            model.OrderStatusesGrid.AutoLoad = true;

            model.OrderStatusesGrid.HasTableBorderedClass = true;
            model.OrderStatusesGrid.HasTableStripedClass  = false;

            return(View(model));
        }
コード例 #5
0
        public async Task <IList <OrderViewModel> > GetByUserId(UserViewModel userInfo, bool isAdmin)
        {
            IEnumerable <Order> orders;

            if (!isAdmin)
            {
                orders = await unitOfWork.Repository <Order>().Get(order => order.ApplicationUser_Id == userInfo.Id);
            }
            else
            {
                orders = await unitOfWork.Repository <Order>().Get();
            }

            IList <OrderViewModel> vOrders = new List <OrderViewModel>();

            foreach (Order order in orders)
            {
                //IEnumerable<OrderStatus> orderStatuses = unitOfWork.Repository<OrderStatus>().Get(orderstatus => orderstatus.Order_Id == order.ID);
                OrderViewModel vOrder = new OrderViewModel();
                vOrder.ID = order.ID;
                vOrder.ApplicationUser_Id = order.ApplicationUser_Id;
                var user = userManager.Users.Single(u => u.Id == order.ApplicationUser_Id);
                vOrder.CompanyName        = user?.CompanyName;
                vOrder.Number             = order.Number;
                vOrder.Mark               = order.Mark;
                vOrder.ContainerNumber    = order.ContainerNumber;
                vOrder.Destination        = order.Destination;
                vOrder.DischargedPort     = order.DischargedPort;
                vOrder.BLNumber           = order.BLNumber;
                vOrder.ETD                = order.ETD;
                vOrder.ETA                = order.ETA;
                vOrder.NumbOfGoods        = order.NumbOfGoods;
                vOrder.Weight             = order.Weight;
                vOrder.Measurement        = order.Measurement;
                vOrder.ProductDescription = order.ProductDescription;
                vOrder.ReceiveOrderDate   = order.ReceiveOrderDate;

                if (order.Statuses != null)
                {
                    IList <OrderStatusViewModel> vOrderStatuses = new List <OrderStatusViewModel>();
                    foreach (OrderStatus status in order.Statuses)
                    {
                        var vOrderStatus = new OrderStatusViewModel
                        {
                            Id          = status.ID,
                            date        = status.date.ToString(),
                            description = status.description
                        };
                        vOrderStatuses.Add(vOrderStatus);
                    }
                    vOrder.Statuses = vOrderStatuses;
                }

                vOrders.Add(vOrder);
            }

            return(vOrders);
        }
コード例 #6
0
        public async Task <IActionResult> CreateOrderStatusAsync([FromBody] OrderStatusViewModel value)
        {
            var response = new SingleModelResponse <OrderStatusViewModel>() as ISingleModelResponse <OrderStatusViewModel>;

            try
            {
                var entity = await Task.Run(() =>
                {
                    return(_RESTfulAPI_Repository.AddOrderStatus(value.ToEntity()));
                });

                if (response.DidError == false)
                {
                    response.Model = entity.ToViewModel();
                }
            }
            catch (Exception ex)
            {
                string webRoot   = _hostingEnvironment.WebRootPath;
                string errorGuid = String.Format(Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 16));

                HttpContext.Session.SetString("ErrorGuid", errorGuid);
                ViewBag.ErrorGuid = HttpContext.Session.GetString("ErrorGuid");

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    using (StreamWriter w = new StreamWriter(webRoot + "\\log.txt", append: true))
                    {
                        Log.Logging(ex.ToString(), w, ViewBag.ErrorGuid);
                    }
                }

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                {
                    using (StreamWriter w = new StreamWriter(webRoot + "/log.txt", append: true))
                    {
                        Log.Logging(ex.ToString(), w, ViewBag.ErrorGuid);
                    }
                }


                response.DidError = true;
                //response.ErrorMessage = ex.ToString();


                return(this.Json(new { timestamp = DateTime.Now, errorGuid = ViewBag.ErrorGuid, status = HttpStatusCode.InternalServerError, info = "Error logged in log file." }));
            }



            response.Info = "Client " + " " + HttpContext.Connection.RemoteIpAddress.ToString();

            return(response.ToHttpResponse());
        }
コード例 #7
0
        public async Task <IActionResult> Status(OrderStatusViewModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(this.ordersService.LoadOrderStatusModel(input.Id)));
            }

            await this.ordersService.UpdateOrderStatusAsync(input);

            this.notyfService.Success(this.localizer["Order updated."]);
            return(this.RedirectToAction(GlobalConstants.Index));
        }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        public static OrderStatus ToEntity(this OrderStatusViewModel viewModel)
        {
            return(viewModel == null ? null : new OrderStatus
            {
                Id = viewModel.Id,
                Status_Name = viewModel.Status_Name

                              //
                              //RowGuid = viewModel.RowGuid,
                              //ModifiedDate = viewModel.ModifiedDate
            });
        }
コード例 #9
0
        public async Task <ActionResult <OrderStatusViewModel> > Post(OrderStatusViewModel orderStatus)
        {
            var response = await _orderStatusService.Create(orderStatus.ToModel());

            if (response != BusinessLogic.Enums.StatusCode.Created)
            {
                _logger.LogError($"OrderStatus {orderStatus.Name} not found.");
            }

            return(response == BusinessLogic.Enums.StatusCode.Created
                ? (ActionResult <OrderStatusViewModel>)Ok()
                : Conflict());
        }
コード例 #10
0
        public ActionResult CreateOrder(PlaceOrderViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("PlaceOrder", viewModel));
            }
            OrderStatusViewModel vm        = Mapper.Map <PlaceOrderViewModel, OrderStatusViewModel>(viewModel);
            List <OrderDet>      orderDets = new List <OrderDet>();
            Order ord = new Order();

            ord           = Mapper.Map <PlaceOrderViewModel, Order>(viewModel);
            ord.OrderDets = new List <OrderDet>();
            vm.TotalPrice = "0";

            //Xu ly concurrency
            for (int i = 0; i < viewModel.Carts.Count(); i++)
            {
                Product pr  = Mapper.Map <ProductShoppingCart, Product>(viewModel.Carts[i]);
                Product pr1 = productService.GetById(viewModel.Carts[i].Id);
                if (productService.CheckConcurency(pr))
                {
                    int qty = viewModel.Carts[i].BuyingQuantity;
                    viewModel.Carts[i] = Mapper.Map <Product, ProductShoppingCart>(pr1);
                    viewModel.Carts[i].BuyingQuantity = qty;
                    viewModel.Carts[i].TotalPrice     = (viewModel.Carts[i].BuyingQuantity * double.Parse((viewModel.Carts[i].PromotionalPrice == "1" ? viewModel.Carts[i].Price : viewModel.Carts[i].PromotionalPrice).Replace(".", ""))).ToString();

                    ModelState.AddModelError("ConcurrencyError", "Sản phẩm " + pr1.Name + " đã bị thay đổi thông tin, vui lòng xem lại sản phẩm trước khi mua");
                    return(View("PlaceOrder", viewModel));
                }
                int qty1 = viewModel.Carts[i].BuyingQuantity;
                if (qty1 > pr1.Quantity)
                {
                    ModelState.AddModelError("QuantityError", "Đồng hồ " + pr1.Name + " không còn đủ hàng. Vui lòng chọn số lượng ít hơn.");
                    return(View("PlaceOrder", viewModel));
                }
                pr = productService.GetById(viewModel.Carts[i].Id);

                vm.TotalPrice = (pr.PromotionalPrice == 1?pr.Price * viewModel.Carts[i].BuyingQuantity:pr.PromotionalPrice * viewModel.Carts[i].BuyingQuantity).ToString();
                OrderDet det = new OrderDet();
                det.Quantity     = viewModel.Carts[i].BuyingQuantity;
                det.ProductId    = viewModel.Carts[i].Id;
                det.ProductPrice = pr.PromotionalPrice == 1 ? pr.Price : pr.PromotionalPrice;
                det.Order        = ord;
                ord.OrderDets.Add(det);
                ord.TotalCost += det.ProductPrice * det.Quantity;
            }
            vm.TotalPrice = PriceHelper.NormalizePrice(vm.TotalPrice);
            orderService.AddOrder(ord);
            Session["Carts"] = null;
            return(View("OrderStatus", vm));
        }
コード例 #11
0
        public IActionResult Status(string id)
        {
            if (Request.QueryString.HasValue)
            {
                if (Request.Query.ContainsKey("preference_id"))
                {
                    if (Request.Query["preference_id"].ToString() == _cartRepository.GetMpPreference(_cartRepository.GetSessionCartId()))
                    {
                        _cartRepository.RenewId();
                    }
                }

                Task.Run(async() =>
                {
                    var apicall = $"http://{Request.Host.ToString()}/api/WebhooksData/OnPaymentNotNotified";
                    await new HttpClient().GetAsync(apicall);
                });
            }

            Order order = _orderRepository.GetOrderByBookingId(id);
            OrderStatusViewModel orderstatus;

            if (order == null)
            {
                orderstatus = new OrderStatusViewModel()
                {
                    BookingId    = id ?? string.Empty,
                    Notification = null,
                    Payment      = null,
                    Progress     = null
                };
            }
            else
            {
                orderstatus = new OrderStatusViewModel()
                {
                    BookingId    = id ?? string.Empty,
                    Notification = _orderRepository.GetEmailData(order.OrderId),
                    Payment      = order.OrderPaymentStatus,
                    Progress     = order.OrderProgressState
                };
            }
            return(View(orderstatus));
        }
コード例 #12
0
        public async Task <IActionResult> Status(string id)
        {
            if (Request.QueryString.HasValue)
            {
                if (Request.Query.ContainsKey("preference_id"))
                {
                    if (Request.Query["preference_id"].ToString() == _cartRepository.GetMpPreference(_cartRepository.GetSessionCartId()))
                    {
                        _cartRepository.RenewId();
                    }
                }
            }

            Order order = await _orderRepository.GetOrderByFriendlyBookingId(id);

            OrderStatusViewModel orderstatus;

            if (order == null)
            {
                orderstatus = new OrderStatusViewModel()
                {
                    BookingId    = id ?? string.Empty,
                    Notification = null,
                    Payment      = null,
                    Progress     = null
                };
            }
            else
            {
                var not = await _orderRepository.GetEmailDataAsync(order.OrderId);

                orderstatus = new OrderStatusViewModel()
                {
                    BookingId    = id ?? string.Empty,
                    Notification = not,
                    Payment      = order.OrderPaymentStatus,
                    Progress     = order.OrderProgressState
                };
            }
            return(View(orderstatus));
        }
コード例 #13
0
        public ActionResult OrderCancelConfirm(int odNo)
        {
            if (Session["Customer"] == null)
            {
                return(Redirect("/CustomerLogin/CustomerLoginIndex"));
            }
            using (var db = new ModelContext())
            {
                var osvmList = new List <OrderStatusViewModel>();

                var orderDetailList = (from e in db.OrderDetails
                                       where e.OrderNo == odNo
                                       select e).ToList();
                for (int i = 0; i < orderDetailList.Count(); i++)
                {
                    var osvm = new OrderStatusViewModel(orderDetailList[i]);
                    osvmList.Add(osvm);
                }
                return(View(osvmList));
            }
        }
コード例 #14
0
        public async Task <IActionResult> UpdateOrderStatusAsync(Int32 id, [FromBody] OrderStatusViewModel value)
        {
            var response = new SingleModelResponse <OrderStatusViewModel>() as ISingleModelResponse <OrderStatusViewModel>;

            try
            {
                var entity = await Task.Run(() =>
                {
                    return(_RESTfulAPI_Repository.UpdateOrderStatus(id, value.ToEntity()));
                });



                response.Model = entity.ToViewModel();
                response.Info  = "The record was updated successfully";
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
コード例 #15
0
        public async Task <IActionResult> UpdateOrderStatus(OrderStatusViewModel orderStatusViewModel)
        {
            await orderService.UpdateOrderStatus(orderStatusViewModel.id, orderStatusViewModel.status_id);

            return(Ok());
        }
コード例 #16
0
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Call LUIS, try and identify what the user is trying to do.
            //If the entities are included in the response, convert them to a viewmodel and user them, otherwise prompt the user for the missing data.
            var luisResult = await _luisRecognizer.RecognizeAsync <IVR>(stepContext.Context, cancellationToken);

            switch (luisResult.TopIntent().intent)
            {
            case IVR.Intent.FindNearestStore:
                //Get Luis model and convert it to an easier to work with viewmodel
                var nearestStoreResult    = luisResult.Entities.ToObject <FindNearestStoreModel>();
                var nearestStoreViewModel = new StoreLocationViewModel();

                if (nearestStoreResult.StoreLocation != null && nearestStoreResult.StoreLocation.Length > 0)
                {
                    var storeLocation = nearestStoreResult.StoreLocation.First();
                    if (storeLocation.City.Length > 0)
                    {
                        nearestStoreViewModel.City = storeLocation.City.First();
                    }
                    if (storeLocation.State.Length > 0)
                    {
                        nearestStoreViewModel.State = storeLocation.State.First();
                    }
                }

                return(await stepContext.ReplaceDialogAsync(nameof(NearestStoreDialog), nearestStoreViewModel));

            case IVR.Intent.OrderStatus:
                var orderStatusResult    = luisResult.Entities.ToObject <OrderStatusModel>();
                var orderStatusViewModel = new OrderStatusViewModel();

                if (orderStatusResult.OrderNumber != null && orderStatusResult.OrderNumber.Length > 0)
                {
                    orderStatusViewModel.OrderNumber = orderStatusResult.OrderNumber.First();
                }

                return(await stepContext.ReplaceDialogAsync(nameof(OrderStatusDialog), orderStatusViewModel));

            case IVR.Intent.Cancel:
                //If the user indicates that they are done with the call, leave a message and hangup.
                var goodbyeMessage = VoiceFactory.TextAndVoice(HangupText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(goodbyeMessage, cancellationToken);

                await Task.Delay(3000);     //Temporary hack to make sure that the message has finished being read. Bug is tracked to fix this issue.

                //End of conversation activity currently causes a HangUp. This functionality is experimental, and the API might change.
                await stepContext.Context.SendActivityAsync(Activity.CreateEndOfConversationActivity(), cancellationToken);

                return(await stepContext.EndDialogAsync());

            default:
                // Catch all for unhandled intents
                var didntUnderstandMessageText = $"Sorry, I didn't get that. Please try asking in a different way (intent was {luisResult.TopIntent().intent}). What I heard was {stepContext.Context.Activity.Text}";
                var didntUnderstandMessage     = VoiceFactory.TextAndVoice(didntUnderstandMessageText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(didntUnderstandMessage, cancellationToken);

                break;
            }

            return(await stepContext.NextAsync(null, cancellationToken));
        }
コード例 #17
0
 public static OrderStatus ToModel(this OrderStatusViewModel model) => Mapper.Map <OrderStatus>(model);
コード例 #18
0
ファイル: AdminController.cs プロジェクト: azericoders/EShop
 public ActionResult ChangeOrderStatus(OrderStatusViewModel model)
 {
     return(View("Order"));
 }