Exemplo n.º 1
0
 public ActionResult Delete(int id, PropertyViewModel propertyViewModel)
 {
     try
     {
         Property property = PropertyMapper.ToProperty(propertyViewModel);
         _propertyBusiness.DeleteProperty(property);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Delete(int id, PropertyViewModel propertyViewModel)
 {
     try
     {
         bool result = _propertyBusiness.DeleteProperty(id);
         if (result)
         {
             return(RedirectToAction(nameof(Index)));
         }
         else
         {
             ModelState.AddModelError(string.Empty, "Property cannot be deleted because it may be associated with units. Please unassign this property with units and then delete. ");
             Property          property = _propertyBusiness.GetPropertyDetails(id);
             PropertyViewModel propertyViewModelData = PropertyMapper.ToPropertyViewModel(property);
             return(View(propertyViewModelData));
         }
     }
     catch
     {
         return(View());
     }
 }