public Task <UsersGetViewModel> Update(UsersPutViewModel entity) { var entityDb = _context.users.FirstOrDefault(x => x.Id == entity.Id); if (entityDb == null) { throw new BitsaEntityToEditNotFoundException(); } _mapper.Map(entity, entityDb); //db.Entry(model).Property(x => x.Balance).State = PropertyState.Unmodified; _context.SaveChanges(); return(Task.FromResult(_mapper.Map <UsersGetViewModel>(entityDb))); }
public async Task <IActionResult> Put([FromRoute] int id, [FromBody] UsersPutViewModel entity) { try { if (id != entity.Id) { throw new HttpStatusCodeException(HttpStatusCode.BadRequest, "Identificador incorrecto"); } return(Accepted(await _adminService.Update(entity))); } catch (Exception ex) { throw ex; } }
public Task <UsersGetViewModel> Update(UsersPutViewModel entity) { return(_adminRepository.Update(entity)); }