예제 #1
0
 public ActionResult EditSector(EditSector ae)
 {
     if (ModelState.IsValid)
     {
         using (mmpEntities mP = new mmpEntities())
         {
             #region Sector Already Exists
             var isSectorExists = IsSectorExist(ae.sector_name);
             if (isSectorExists)
             {
                 ModelState.AddModelError("SectorExists", "Sector already exists");
                 return(View(ae));
             }
             #endregion
             sector sector = new sector()
             {
                 sector_id   = ae.sector_id,
                 sector_name = ae.sector_name
             };
             mP.Entry(sector).State = EntityState.Modified;
             mP.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
     return(View());
 }
예제 #2
0
 public ActionResult EditSector(int id = 0)
 {
     using (mmpEntities mP = new mmpEntities())
     {
         var        sector = mP.sectors.Where(x => x.sector_id == id).FirstOrDefault <sector>();
         EditSector ae     = new EditSector()
         {
             sector_id   = sector.sector_id,
             sector_name = sector.sector_name
         };
         return(View(ae));
     }
 }