示例#1
0
        public ActionResult Save(ImportMasterModel model, List <ImportDetailViewModel> detail, decimal TotalShippingWeight, decimal?GuestAmountPaid, DateTime ExchangeDate, int CreateReceipt = 1)
        {
            string resuilt = "";
            ImportMasterRepository ImportMasterRepo = new ImportMasterRepository(_context);

            resuilt = ImportMasterRepo.Save(model, detail, TotalShippingWeight, GuestAmountPaid, ExchangeDate, CreateReceipt, currentAccount.UserName, currentEmployee.EmployeeId);
            return(Json(resuilt, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public ActionResult SaveConfirm(ImportMasterModel model, List <PreImportDetailViewModel> detail, decimal TotalShippingWeight, decimal?GuestAmountPaid, DateTime ExchangeDate, int PreImportMasterId, string StatusCode, int CreateReceipt = 1)
        {
            if (StatusCode.Equals("DADUYET") || StatusCode.Equals("HUY"))
            {
                return(Json("Yêu cầu đơn đặt hàng này đã được duyệt hoặc bị huỷ", JsonRequestBehavior.AllowGet));
            }
            #region // Lấy danh sách sản phẩm có ComfirmQty > 0
            var Lstdetail = (from p in detail
                             where p.ConfirmQty > 0
                             select new ImportDetailViewModel()
            {
                ProductId = p.ProductId,
                Qty = p.ConfirmQty,
                Price = p.Price,
                UnitShippingWeight = p.UnitShippingWeight,
                UnitPrice = p.UnitPrice,
                Note = p.Note,
                ShippingFee = p.ShippingFee,
                UnitCOGS = p.UnitCOGS
            }).ToList();
            model.TotalQty = Lstdetail.Count;
            #endregion

            // Bước 1 : Tính toán tương tự ImportMaster
            ImportMasterRepository ImportRepo = new ImportMasterRepository(_context);
            string Resuilt = ImportRepo.Save(model, Lstdetail, TotalShippingWeight, GuestAmountPaid, ExchangeDate, CreateReceipt, currentAccount.UserName, currentEmployee.EmployeeId);

            // Bước 2 : Cập nhật lại các field bên PreImportMaster : StatusCode , ImportMasterId
            if (Resuilt.Equals("success"))
            {
                var PreImportModel = _context.PreImportMasterModel.Where(p => p.PreImportMasterId == PreImportMasterId).FirstOrDefault();
                PreImportModel.ImportMasterId        = model.ImportMasterId;
                PreImportModel.StatusCode            = "DADUYET";
                _context.Entry(PreImportModel).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
            }
            return(Json(Resuilt, JsonRequestBehavior.AllowGet));
        }