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

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

            domainModel.ID      = viewModel.ID;
            domainModel.NO      = viewModel.NO;
            domainModel.Remark  = viewModel.Remark;
            domainModel.Details = (from d in viewModel.Details
                                   select new DomainModels.StocktakeReceiptDeatil
            {
                ID = viewModel.ID,
                TakeQuantity = d.TakeQuantity,
                BookID = d.BookID
            }).ToList();

            return(domainModel);
        }
Beispiel #3
0
        public static ViewModels.StocktakeReceipt CopyToViewModel(this DomainModels.StocktakeReceipt domainModel, ViewModels.StocktakeReceipt viewModel = null)
        {
            if (viewModel == null)
            {
                viewModel = new ViewModels.StocktakeReceipt();
            }

            viewModel.ID      = domainModel.ID;
            viewModel.NO      = domainModel.NO;
            viewModel.Remark  = domainModel.Remark;
            viewModel.Details = (from d in domainModel.Details
                                 select new StocktakeReceiptDetail
            {
                ID = d.ID,
                TakeQuantity = d.TakeQuantity,
                AccountPrice = d.Book.AccountPrice.GetValueOrDefault(),
                BookID = d.BookID,
                ISBN = d.Book.ISBN,
                BookName = d.Book.Name
            }).ToList();

            return(viewModel);
        }