public ActionResult Create(Category Model) { if (!this.ModelState.IsValid) { this.View(Model); } Model.EntityId = Guid.NewGuid(); Model.CreatedBy = this.User.Identity.Name; Model.CreatedOn = DateTime.Now; Context.Categories.Add(Model); Context.SaveChanges(); return this.RedirectToAction("Index"); }
public ActionResult Edit(Category Model) { //development chagne var category = this.Context.Categories.Find(Model.Id); if (category == null) { return this.HttpNotFound(); } else { try { this.UpdateModel(category, "", new string[] { "Name", "Description" }); this.Context.SaveChanges(); return this.RedirectToAction("Index"); } catch (Exception ex) { this.ModelState.AddModelError("", ex); return this.View(category); } } }