Exemplo n.º 1
0
        public int DeleteDeviceType(DeviceTypeDto model)
        {
            DeviceType tblDevice = Mapper.Map <DeviceTypeDto, DeviceType>(model);

            _deviceTypeRepository.DeleteDeviceType(tblDevice, _dbContext);
            return(_dbContext.SaveChanges());
        }
Exemplo n.º 2
0
        /// <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");
        }
Exemplo n.º 4
0
 public ActionResult DeleteConfirmed(long id)
 {
     try
     {
         _repository.DeleteDeviceType(id, GetUserId());
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         ExceptionMessageToViewBag(e);
         return(View("Error"));
     }
 }
Exemplo n.º 5
0
        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));
            }
        }