public virtual ActionResult EditTransaction(StockTransactionEditVM vm) { if (ModelState.IsValid) { var model = Mapper.Map <StockTransaction>(vm); var data = DataContext.StockTransactions.Where(w => w.Id == model.Id).First(); data.Date = model.Date; data.Description = model.Description; data.Input = model.Input; data.Output = model.Output; data.ProductRef = model.ProductRef; DataContext.SubmitChanges(); TempData["ResultMessage"] = "Hareket Güncellendi"; return(RedirectToAction("hareketler")); } else { ViewBag.Products = DataContext.Products.Select(s => new { Id = s.Id, Name = s.Name }).ToList() .Select(s => new Product { Id = s.Id, Name = s.Name }).ToList(); return(View("Transaction", vm)); } }
public virtual ActionResult NewTransaction(StockTransactionEditVM vm) { ViewBag.Products = DataContext.Products.Select(s => new { Id = s.Id, Name = s.Name }).ToList() .Select(s => new Product { Id = s.Id, Name = s.Name }).ToList(); if (ModelState.IsValid) { DataContext.StockTransactions.InsertOnSubmit(Mapper.Map <StockTransaction>(vm)); DataContext.SubmitChanges(); TempData["ResultMessage"] = "Stok Hareketi Eklendi"; return(RedirectToAction("hareketler")); } return(View("Transaction", vm)); }