private static void UpdateUser() { Console.Write("\nEnter User ID: "); userDTO.UserId = int.Parse(Console.ReadLine()); Console.Write("\nEnter User Name : "); userDTO.Name = Console.ReadLine(); Console.Write("\nEnter User Age: "); string age = Console.ReadLine(); if (age != "" && age.Trim() != "") { userDTO.Age = int.Parse(age); } else { userDTO.Age = -1; } Console.Write("\nEnter User Gender: "); userDTO.Gender = Console.ReadLine(); if (userBDC.UpdateUser(userDTO)) { Console.WriteLine("User successfully updated with ID: {0}", userDTO.UserId); IUserDTO retrievedUserDTO = userBDC.GetAUser(userDTO.UserId); PrintJSONifyUserDTO(retrievedUserDTO); } else { Console.WriteLine("Operation could not be successful. Please try again."); } }
public HttpResponseMessage ApproveUser([FromBody] ApproverAPIID approverId, [FromUri] int userId) { try { UserAPIModel user = mapper.Map <UserAPIModel>(userBDC.GetUserById(userId)); if (user == null) { return(Request.CreateResponse(HttpStatusCode.OK, false)); } else { if (user.CurrentStatus == APIModels.status.Pending) { user.CurrentStatus = APIModels.status.Approved; user.ApprovedBy = approverId.ApproverId; UserDTO userToUpdate = mapper.Map <UserDTO>(user); if (userBDC.UpdateUser(userToUpdate)) { return(Request.CreateResponse(HttpStatusCode.OK, true)); } else { return(Request.CreateResponse(HttpStatusCode.OK, false)); } } else { return(Request.CreateResponse(HttpStatusCode.OK, false)); } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); return(Request.CreateResponse(HttpStatusCode.Forbidden, e)); } }
public IHttpActionResult Put(int id, [FromBody] UserDTO userDTO) { IUserBDC userBDC = (IUserBDC)BDCFactory.Instance.Create(BDCType.UserBDC); IUserDTO userDTOs = (IUserDTO)DTOFactory.Instance.Create(DTOType.UserDTO); userDTOs.UserID = id; userDTOs.AccountBalance = userDTO.AccountBalance; OperationResult <IUserDTO> retVal = userBDC.UpdateUser(userDTOs); if (retVal.IsValid()) { return(Ok(retVal.Data.UserID)); } return(NotFound()); }
public OperationResult <IUserDTO> UpdateUser(int persondid, int amt) { IUserBDC UserBDC = (IUserBDC)BDCFactory.Instance.Create(BDCType.UserBDC); return(UserBDC.UpdateUser(persondid, amt)); }