Esempio n. 1
0
        public ActionResult Delete(RegionViewModel regionViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    regionViewModel.DeleteRegion(regionViewModel);
                    return(RedirectToAction("Index", "Region"));
                }

                return(RedirectToAction("Index", "Region"));
            }
            catch (DbUpdateException exception)
            {
                //Log Exception
                errorlogviewmodel = new ErrorLogViewModel();
                errorlogviewmodel.LogError(exception);

                //Check for Referential Integrity
                if (((System.Data.SqlClient.SqlException)exception.InnerException.InnerException).Number == 547)
                {
                    return(View("Error_ReferentialIntegrity"));
                }

                return(View("Error"));
            }


            catch (Exception ex)
            {
                errorlogviewmodel = new ErrorLogViewModel();
                errorlogviewmodel.LogError(ex);
                return(View("Error"));
            }
        }