Ejemplo n.º 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"));
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> DeleteRegion(int regionId)
        {
            var regionEntity = await _regionRepository.GetRegion(regionId);

            if (regionEntity == null)
            {
                return(NotFound());
            }

            _regionRepository.DeleteRegion(regionEntity);
            await _regionRepository.SaveChanges();

            return(NoContent());
        }
Ejemplo n.º 3
0
        public IActionResult DeleteRegion(int id)
        {
            try
            {
                var region = _regionRepository.ReadRegion(id);
                if (region == null)
                {
                    return(NoContent());
                }

                _regionRepository.DeleteRegion(id);
                return(Ok("Deleted"));
            }
            catch (Exception exception)
            {
                return(BadRequest(exception.Message));
            }
        }
Ejemplo n.º 4
0
        public IActionResult DeleteRegion(int id)
        {
            if (id == 0)
            {
                return(BadRequest());
            }

            var regionToDelete = _regionRepository.GetRegionById(id);

            if (regionToDelete == null)
            {
                return(NotFound());
            }

            _regionRepository.DeleteRegion(id);

            return(NoContent());//success
        }
Ejemplo n.º 5
0
        public HttpResponseMessage Delete([FromBody] Models.region region)
        {
            try
            {
                bool updateRegion = _regionRepository.DeleteRegion(region.region_id);

                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "success", msg = "Region Deleted Successfully."
                }, formatter));
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }
Ejemplo n.º 6
0
 public void DeleteRegion(Region region)
 {
     repository.DeleteRegion(region);
 }