public UserDeletedReturnDto DeleteUserById(int userId) { if (!_userOperations.UserExists(userId)) { return(null); } var user = _userOperations.GetUserById(userId); if (_userOperations.UserIsManager(user)) { _departmentOperations.RemoveManager(user.Department); } var userDeleted = _userOperations.DeleteUser(user); return(userDeleted == null ? null : Mapper.Map <UserDeletedReturnDto>(userDeleted)); }
public HttpResponseMessage Delete(int id) { try { _operations.DeleteUser(id); return(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent($"User {id} deleted") }); } catch (Exception ex) { return(new HttpResponseMessage() { StatusCode = HttpStatusCode.InternalServerError, }); } }