Ejemplo n.º 1
0
        public ActionResult SubmitOrder(OrderModel model)
        {
            var result = new CustomJsonResult();

            try
            {
                if (model.Id == 0)
                {
                    // todo: thay bằng storeId
                    var storeInfo = GetStoreAccountInfo();
                    if (storeInfo.id < 1)
                    {
                        result.Message = "Bạn không có quyền tạo Order";
                    }
                    else
                    {
                        var orderDetail = model.ConvertToOrder();
                        var g           = 0;  foreach (var p in orderDetail.tblPackageInfoes)
                        {
                            g++;
                            p.Code             = Common.Libs.AutoGenPackageID(orderDetail.CreateDate.UnixTimeStampToDateTime(), storeInfo.Code, orderDetail.tblPackageInfoes.Count.ToString() + g.ToString(), _orderService.CountOrderInDay(orderDetail.CreateDate.UnixTimeStampToDateTime(), model.StoreId));
                            p.WarehouseId      = storeInfo.WarehouseId;
                            p.NotifyToCustomer = 0;
                        }
                        result.Result = _orderService.Admin_CreateOrder(orderDetail);
                    }
                }
                else
                {
                    tblOrder detail = model.ConvertToOrder();
                    detail.id     = (int)model.Id;
                    result.Result = _orderService.Admin_UpdateOrder(detail);
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            return(Json(result));
        }
Ejemplo n.º 2
0
        public ActionResult SubmitOrder(OrderModel model)
        {
            var result = new CustomJsonResult();

            try
            {
                if (model.Id == 0)
                {
                    // todo: thay bằng storeId
                    var storeInfo = GetStoreAccountInfo();
                    if (storeInfo.id < 1)
                    {
                        result.Message = "Bạn không có quyền tạo Order";
                    }
                    else
                    {
                        var orderDetail = model.ConvertToOrder();
                        foreach (var p in orderDetail.tblPackageInfoes)
                        {
                            p.WarehouseId = storeInfo.WarehouseId;
                        }
                        result.Result = _orderService.Admin_CreateOrder(orderDetail);
                    }
                }
                else
                {
                    tblOrder detail = model.ConvertToOrder();
                    detail.id     = (int)model.Id;
                    result.Result = _orderService.Admin_UpdateOrder(detail);
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            return(Json(result));
        }
Ejemplo n.º 3
0
        public IHttpActionResult SubmitOrder([FromBody] OrderModel model)
        {
            var response = new Response();

            try
            {
                if (model.Id == 0)
                {
                    // todo: thay bằng storeId

                    var storeid   = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["StoreId"]);
                    var storeInfo = _storeService.SelectStoreByID(storeid);
                    if (storeInfo == null)
                    {
                        response.Message = "Invalid StoreId";
                        return(Json(response));
                    }
                    if (model.Packages == null)
                    {
                        response.Message = "Packages must be not null";
                        return(Json(response));
                    }

                    model.Code = storeInfo.Code;
                    var orderDetail = model.ConvertToOrder();
                    var g           = 0; foreach (var p in orderDetail.tblPackageInfoes)
                    {
                        g++;
                        p.Code             = Libs.AutoGenPackageID(orderDetail.CreateDate.UnixTimeStampToDateTime(), storeInfo.Code, orderDetail.tblPackageInfoes.Count.ToString() + g.ToString(), _orderService.CountOrderInDay(orderDetail.CreateDate.UnixTimeStampToDateTime(), storeid));
                        p.WarehouseId      = storeInfo.WarehouseId;
                        p.NotifyToCustomer = 0;
                    }
                    response.Data = _orderService.Admin_CreateOrderApi(orderDetail);
                }
                else
                {
                    response.Message = "Not using update value";
                    //tblOrder detail = model.ConvertToOrder();
                    //detail.id = (int)model.Id;
                    //response.Data = _orderService.Admin_UpdateOrder(detail);
                }
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(Json(response));
        }
Ejemplo n.º 4
0
 public ActionResult Checkout(OrderModel model)
 {
     if (Session["order"] != null)
     {
         OrderModel.AddOrder(OrderModel.ConvertToOrder(model));
         var order = OrderModel.GetLastOrder();
         foreach (var item in Session["order"] as List <OrderRowModel> )
         {
             item.OrderId = order.Id;
             OrderRowModel.AddOrderRow(OrderRowModel.ConvertToOrderRow(item));
         }
         Session["order"] = null;
         return(RedirectToAction("Receipt"));
     }
     return(RedirectToAction("Index", "Home"));
 }