Example #1
0
        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;
            }
        }
Example #2
0
 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);
 }