Пример #1
0
 public ActionResult SaveOrEdit(Navigation navigation)
 {
     try
     {
         // if (ModelState.IsValid)
         {
             var c = navigation.Modul.Split("-".ToCharArray());
             navigation.ControllerName = c[0];
             navigation.ActionName     = c[1];
             if (navigation.Id == 0)
             {
                 NavigationRepository.Add(navigation);
             }
             else
             {
                 NavigationRepository.Edit(navigation);
             }
             NavigationRepository.Save();
             if (IsSuperAdmin)
             {
                 return(RedirectToAction("Index", new { storeId = navigation.StoreId }));
             }
             else
             {
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex, "Unable to save changes:" + ex.StackTrace, navigation);
         //Log the error (uncomment dex variable name and add a line here to write a log.
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(View(navigation));
 }