public ActionResult SaveNew(SteelProfile steelProfile) { if (!ModelState.IsValid) { return(View("New")); } steelProfile.CreatedByUser = User.Identity.Name; steelProfile.CreatedDate = DateTime.Now; _context.SteelProfiles.Add(steelProfile); _context.SaveChanges(); return(RedirectToAction("Index", "SteelProfiles")); }
public ActionResult SaveEdited(SteelProfile steelProfile) { var steelProfileInDb = _context.SteelProfiles.Single(x => x.Id == steelProfile.Id); steelProfileInDb.Length = steelProfile.Length; steelProfileInDb.Quantity = steelProfile.Quantity; steelProfileInDb.ModifiedByUser = User.Identity.Name; steelProfileInDb.ModifiedDate = DateTime.Now; steelProfileInDb.ProfileDetailsId = steelProfile.ProfileDetailsId; steelProfileInDb.ProjectInformationsId = steelProfile.ProjectInformationsId; steelProfileInDb.StatusId = steelProfile.StatusId; _context.SaveChanges(); return(RedirectToAction("Index", "SteelProfiles")); }