Exemple #1
0
        public ActionResult SaveOutStockReceipt(ViewModels.OutStockReceipt receipt, SaveMode mode)
        {
            DomainModels.OutStockReceipt r = receipt.CopyToDomainModel();
            r.SubmittedBy = LoginUser;
            if (mode == SaveMode.Add)
            {
                ResolveService <IOutStockReceiptService>().SubmitTemporaryReceipt(r);
            }
            else if (mode == SaveMode.Update)
            {
                ResolveService <IOutStockReceiptService>().UpdateTemporaryReceipt(r);
            }
            else
            {
                return(Json(new JsonResultData
                {
                    Success = false,
                    ErrorMessage = "未知的请求类型"
                }));
            }

            return(Json(new JsonResultData
            {
                Success = true
            }));
        }
Exemple #2
0
        public static ViewModels.OutStockReceipt CopyToViewModel(this DomainModels.OutStockReceipt domainModel, ViewModels.OutStockReceipt viewModel = null)
        {
            if (viewModel == null)
            {
                viewModel = new ViewModels.OutStockReceipt();
            }

            viewModel.ID      = domainModel.ID;
            viewModel.NO      = domainModel.NO;
            viewModel.Freight = domainModel.Freight;
            viewModel.OrderNO = domainModel.Order == null ? "" : domainModel.Order.NO;
            viewModel.Remark  = domainModel.Remark;
            viewModel.Details = (from d in domainModel.Details
                                 select new ViewModels.OutStockReceiptDetail
            {
                ID = d.ID,
                OutQuantity = d.OutQuantity,
                OutUnitPrice = d.OutUnitPrice,
                AccountPrice = d.Book.AccountPrice.GetValueOrDefault(),
                BookID = d.BookID,
                ISBN = d.Book.ISBN,
                BookName = d.Book.Name
            }).ToList();

            return(viewModel);
        }
Exemple #3
0
        public static DomainModels.OutStockReceipt CopyToDomainModel(this ViewModels.OutStockReceipt viewModel, DomainModels.OutStockReceipt domainModel = null)
        {
            if (domainModel == null)
            {
                domainModel = new DomainModels.OutStockReceipt();
            }

            domainModel.ID      = viewModel.ID;
            domainModel.NO      = viewModel.NO;
            domainModel.Freight = viewModel.Freight;
            domainModel.Remark  = viewModel.Remark;
            domainModel.Details = (from d in viewModel.Details
                                   select new DomainModels.OutStockReceiptDetail
            {
                ID = d.ID,
                OutQuantity = d.OutQuantity,
                OutUnitPrice = d.OutUnitPrice,
                BookID = d.BookID
            }).ToList();

            return(domainModel);
        }