public int DeleteDeviceType(DeviceTypeDto model) { DeviceType tblDevice = Mapper.Map <DeviceTypeDto, DeviceType>(model); _deviceTypeRepository.DeleteDeviceType(tblDevice, _dbContext); return(_dbContext.SaveChanges()); }
/// <summary> /// Delete device type by id /// </summary> /// <param name="deviceTypeId"></param> /// <returns></returns> public bool DeleteDeviceType(int deviceTypeId) { if (deviceTypeId <= 0) { throw new NsiArgumentException(DeviceTypeMessages.DeviceTypeInvalidArgument); } return(_deviceTypeRepository.DeleteDeviceType(deviceTypeId)); }
public async Task <IActionResult> DeleteDeviceType(int id) { await _repo.DeleteDeviceType(id); if (await _repo.SaveAll()) { return(NoContent()); } throw new Exception("Error deleting the device type"); }
public ActionResult DeleteConfirmed(long id) { try { _repository.DeleteDeviceType(id, GetUserId()); return(RedirectToAction("Index")); } catch (Exception e) { ExceptionMessageToViewBag(e); return(View("Error")); } }
public async Task <IActionResult> DeleteDeviceType(int id) { try { var exist = await _repository.Exist(id); if (!exist) { return(NotFound()); } await _repository.DeleteDeviceType(id); return(NoContent()); } catch (Exception ex) { return(BadRequest(ex)); } }