public void InsertOrUpdate(Label label) { if (label.LabelID == default(long)) { // New entity context.Labels.Add(label); } else { // Existing entity context.Entry(label).State = System.Data.Entity.EntityState.Modified; } }
public ActionResult Edit(Label label) { label.ModificationDate = DateTime.Now; label.ActionDate = DateTime.Now; label.ModifiedBy = (int)Membership.GetUser().ProviderUserKey; if (ModelState.IsValid) { unitofWork.LabelRepository.InsertOrUpdate(label); unitofWork.Save(); return RedirectToAction("Index"); } return View(label); }