public ActionResult Details2(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VendorMilkInfo vendorMilk = db.VendorMilkInfoes.Find(id); if (vendorMilk == null) { return(HttpNotFound()); } VendorMilkViewModel vendorMilkViewModel = new VendorMilkViewModel(); vendorMilkViewModel.Id = vendorMilk.Id; vendorMilkViewModel.FatValue = vendorMilk.FatValue; vendorMilkViewModel.MilkType = vendorMilk.MilkType.MilkType1; vendorMilkViewModel.MilkValue = vendorMilk.MilkValue; vendorMilkViewModel.Price = vendorMilk.Price; vendorMilkViewModel.Total = vendorMilk.Total; vendorMilkViewModel.CreatedBy = db.UserInfoes.FirstOrDefault(q => q.Id == vendorMilk.CreatedBy)?.FirstName; vendorMilkViewModel.UpdateBy = db.UserInfoes.FirstOrDefault(q => q.Id == vendorMilk.UpdatedBy)?.FirstName; vendorMilkViewModel.CreatedDate = vendorMilk.CreatedDate; vendorMilkViewModel.UpdatedDate = vendorMilk.UpdatedDate; vendorMilkViewModel.VendorName = vendorMilk.VendorInfo.VendorName; vendorMilkViewModel.MoneyPaid = vendorMilk.MoneyPaid; return(View(vendorMilkViewModel)); }
public ActionResult DeleteConfirmed(int id) { VendorMilkInfo vendorMilk = db.VendorMilkInfoes.Find(id); db.VendorMilkInfoes.Remove(vendorMilk); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit2(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VendorMilkInfo vendorMilk = db.VendorMilkInfoes.Find(id); if (vendorMilk == null) { return(HttpNotFound()); } VendorMilkViewModel vendorMilkViewModel = new VendorMilkViewModel(); vendorMilkViewModel.Id = vendorMilk.Id; vendorMilkViewModel.VendorId = vendorMilk.VendorId; vendorMilkViewModel.FatValue = vendorMilk.FatValue; vendorMilkViewModel.MilkTypeId = vendorMilk.MilkTypeId; vendorMilkViewModel.MilkValue = vendorMilk.MilkValue; vendorMilkViewModel.Price = vendorMilk.Price; vendorMilkViewModel.Total = vendorMilk.Total; vendorMilkViewModel.CreatedBy = db.UserInfoes.FirstOrDefault(q => q.Id == vendorMilk.CreatedBy)?.FirstName; vendorMilkViewModel.UpdateBy = db.UserInfoes.FirstOrDefault(q => q.Id == vendorMilk.UpdatedBy)?.FirstName; vendorMilkViewModel.CreatedDate = vendorMilk.CreatedDate; vendorMilkViewModel.UpdatedDate = vendorMilk.UpdatedDate; vendorMilkViewModel.MoneyPaid = vendorMilk.MoneyPaid; vendorMilkViewModel.MilkTypeList = db.MilkTypes.ToList().Select(m => new SelectListItem() { Text = m.MilkType1, Value = m.Id.ToString() }).ToList(); vendorMilkViewModel.VendorList = db.VendorInfoes.ToList().Select(m => new SelectListItem() { Text = m.VendorName, Value = m.Id.ToString() }).ToList(); return(View(vendorMilkViewModel)); }
public ActionResult Edit(VendorMilkViewModel vendorMilkViewModel) { if (ModelState.IsValid) { VendorMilkInfo vendorMilk = db.VendorMilkInfoes.Find(vendorMilkViewModel.Id); if (vendorMilk == null) { return(HttpNotFound()); } vendorMilk.VendorId = vendorMilkViewModel.VendorId; vendorMilk.FatValue = vendorMilkViewModel.FatValue; vendorMilk.MilkTypeId = vendorMilkViewModel.MilkTypeId; vendorMilk.MilkValue = vendorMilkViewModel.MilkValue; vendorMilk.Price = vendorMilkViewModel.Price; vendorMilk.Total = vendorMilkViewModel.Total; vendorMilk.UpdatedDate = DateTime.Now; vendorMilk.UpdatedBy = 1; vendorMilk.MoneyPaid = vendorMilkViewModel.MoneyPaid; db.Entry(vendorMilk).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } vendorMilkViewModel.MilkTypeList = db.MilkTypes.ToList().Select(m => new SelectListItem() { Text = m.MilkType1, Value = m.Id.ToString() }).ToList(); vendorMilkViewModel.VendorList = db.VendorInfoes.ToList().Select(m => new SelectListItem() { Text = m.VendorName, Value = m.Id.ToString() }).ToList(); return(View(vendorMilkViewModel)); }