Beispiel #1
0
 public ActionResult Delete(string id = "")
 {
     Logger.Debug("Inside Region Controller- Delete");
     try
     {
         if (Session["OrganizationGUID"] != null)
         {
             int count = _ITerritoryRepository.GetTerritoryByRegionGUID(new Guid(id)).Count();
             if (count == 0)
             {
                 RegionModel region = new RegionModel();
                 region.RegionGUID = id;
                 _IMarketRepository.DeleteMarketByRegionGUID(new Guid(region.RegionGUID));
                 _ITerritoryRepository.DeleteTerritoryByRegionGUID(new Guid(region.RegionGUID));
                 _IRegionRepository.DeleteRegion(new Guid(region.RegionGUID));
                 //_IRegionRepository.Save();
                 return(RedirectToAction("../MyCompany/Index/Regions"));
             }
             else
             {
                 TempData["msg"] = "<script>ModalPopupsAlert('Workers-In-Motion','Region is associate with Territory.');</script>";
                 return(RedirectToAction("../MyCompany/Index/Regions"));
             }
         }
         else
         {
             return(RedirectToAction("SessionTimeOut", "User"));
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
         return(RedirectToAction("../MyCompany/Index/Regions"));
     }
 }