예제 #1
0
        public ActionResult Edit(ManagementEntity ManagementEntity)
        {
            if (ModelState.IsValid)
            {

                repository.SaveManagementEntity(ManagementEntity);
                TempData["message"] = string.Format("{0} has been saved", ManagementEntity.Description);
                return RedirectToAction("Index");
            }
            else
            {
                //there is something wrong with the data values
                return View(ManagementEntity);
            }
        }
예제 #2
0
 public void SaveManagementEntity(ManagementEntity managementEntity)
 {
     if (managementEntity.ManagementEntityID == 0)
     {
         managementEntity.LastModified = DateTime.UtcNow;
         managementEntity.LastModifiedBy = "System";
         managementEntity.RecordAdded = DateTime.UtcNow;
         managementEntity.RecordAddedBy = "System";
         context.ManagementEntities.Add(managementEntity);
     }
     else
     {
         ManagementEntity dbEntry = context.ManagementEntities.Find(managementEntity.ManagementEntityID);
         if (dbEntry != null)
         {
             dbEntry.LastModified = DateTime.UtcNow;
             dbEntry.LastModifiedBy = "System";
             dbEntry.Description = managementEntity.Description;
             dbEntry.CanContainManagementUnits = managementEntity.CanContainManagementUnits;
             dbEntry.CompanyID = managementEntity.CompanyID;
         }
     }
     context.SaveChanges();
 }