//Update user information //Input: ClientDatePhoneSexDTO, clientId //Output: boolean result if the operation is successful public static bool UpdateInformation(ClientDatePhoneSexDTO client, string clientId) { SwapDbConnection db = new SwapDbConnection(); client user = db.clients.FirstOrDefault(c => c.client_id == clientId); if (user == null) { return(false); } user.birthday_date = client.birthday_date ?? user.birthday_date; user.phone = client.phone ?? user.phone; user.sex = client.sex ?? user.sex; db.SaveChanges(); return(true); }
public HttpResponseMessage UpdateInformation(string userId, ClientDatePhoneSexDTO client) { try { if (client == null || (client.birthday_date == null && string.IsNullOrEmpty(client.phone) && string.IsNullOrEmpty(client.sex))) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Illegal Prameters")); } bool result = clientService.UpdateInformation(client, userId); if (!result) { return(Request.CreateResponse(HttpStatusCode.NotFound, "Client not found")); } return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "There was an InternalServerError: " + e)); } }