Exemplo n.º 1
0
        public async Task <IActionResult> GetOrderStatuses(int orderId)
        {
            OrderStatus orderStatus = await orderStatusRepository.GetByOrderId(orderId);


            if (orderStatus != null)
            {
                return(Json(new
                {
                    success = true,
                    ordered = orderStatus.Ordered,
                    orderedDate = orderStatus.OrderedDate.ToString("MM/dd/yyyy"),
                    abroadWarehouse = orderStatus.AbroadWarehouse,
                    abroadWarehouseDate = orderStatus.AbroadWarehouseDate.ToString("MM/dd/yyyy"),
                    onWay = orderStatus.OnWay,
                    onWayDate = orderStatus.OnWayDate.ToString("MM/dd/yyyy"),
                    customsControl = orderStatus.CustomsControl,
                    customsControlDate = orderStatus.CustomsControlDate.ToString("MM/dd/yyyy"),
                    bakuWarehouse = orderStatus.BakuWarehouse,
                    bakuWarehouseDate = orderStatus.BakuWarehouseDate.ToString("MM/dd/yyyy"),
                    courier = orderStatus.Courier,
                    courierDate = orderStatus.CourierDate.ToString("MM/dd/yyyy"),
                    Return = orderStatus.Return,
                    returnDate = orderStatus.ReturnDate.ToString("MM/dd/yyyy"),
                    completed = orderStatus.Completed,
                    completedDate = orderStatus.CompletedDate.ToString("MM/dd/yyyy")
                }));
            }
            return(Json(new { success = false }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> EditOrder(CustomerEditOrderViewModel model)
        {
            if (ModelState.IsValid)
            {
                Order order = new Order();

                mapper.Map(model, order);
                order.OrderCargoPrice = CalculateCargoPrice(model.OrderWeight);
                var result = await orderRepository.Edit(order);

                OrderStatus orderStatus = await orderStatusRepository.GetByOrderId(model.Id);

                if (result && orderStatus != null)
                {
                    await UpdateStatus(orderStatus, model.Status);

                    return(RedirectToAction("Orders", "Customer", new { id = model.UserId }));
                }
            }
            return(View(model));
        }