public ActionResult Add() { IncomeViewModel viewModel = new IncomeViewModel(); viewModel.Products = Products(); return View(viewModel); }
public static IncomeViewModel From(elfam.web.Models.Income income) { IncomeViewModel model = new IncomeViewModel(); model.BuyPrice = income.BuyPrice; model.IncomeId = income.Id; model.ProductId = income.Product.Id; model.Quantity = income.QuantityCurrent; return model; }
public static IncomeViewModel From(elfam.web.Models.Income income) { IncomeViewModel model = new IncomeViewModel(); model.BuyPrice = income.BuyPrice; model.IncomeId = income.Id; model.ProductId = income.Product.Id; model.Quantity = income.QuantityCurrent; return(model); }
public ActionResult Edit(IncomeViewModel viewModel) { if (!ModelState.IsValid) { viewModel.Products = Products(); return View(viewModel); } Income income = daoTemplate.FindByID<Income>(viewModel.IncomeId); income.BuyPrice = viewModel.BuyPrice; income.Product = daoTemplate.FindByID<Product>(viewModel.ProductId); income.QuantityCurrent = viewModel.Quantity; daoTemplate.Save(income); return RedirectToAction("List"); }
public ActionResult Add(IncomeViewModel viewModel) { if (!ModelState.IsValid) { viewModel.Products = Products(); return View(viewModel); } Income income = new Income(); income.Date = DateTime.Now; income.BuyPrice = viewModel.BuyPrice; income.Product = daoTemplate.FindByID<Product>(viewModel.ProductId); income.Category = income.Product.Category; income.QuantityCurrent = viewModel.Quantity; income.QuantityInital = viewModel.Quantity; daoTemplate.Save(income); return RedirectToAction("List"); }