public bool UpdateUserProfile(ClientAccountUpdateModel model, string userId) { var client = _context.Clients.Where(x => x.ClientId == userId).FirstOrDefault(); if (client == null) { return(false); } client.FirstName = string.IsNullOrEmpty(model.FirstName)?client.FirstName: model.FirstName; client.LastName = string.IsNullOrEmpty(model.LastName) ? client.LastName : model.LastName; client.PhoneNumber = string.IsNullOrEmpty(model.PhoneNumber) ? client.PhoneNumber : model.PhoneNumber; client.Email = string.IsNullOrEmpty(model.Email) ? client.Email : model.Email; client.Address = string.IsNullOrEmpty(model.Address) ? client.Address : model.Address; client.City = string.IsNullOrEmpty(model.City) ? client.City : model.City; client.ChronicDiseases = string.IsNullOrEmpty(model.ChronicDiseases) ? client.ChronicDiseases : model.ChronicDiseases; client.Diagnose = string.IsNullOrEmpty(model.Diagnose) ? client.Diagnose : model.Diagnose; client.HistoryOfCriticalIllness = string.IsNullOrEmpty(model.HistoryOfCriticalIllness) ? client.HistoryOfCriticalIllness : model.HistoryOfCriticalIllness; client.BloodType = model.BloodType.HasValue? model.BloodType: client.BloodType; _context.SaveChanges(); return(true); }
public IHttpActionResult UpdateUserAccountInformation([FromBody] ClientAccountUpdateModel clientAccountUpdateModel) { var result = _clientService.UpdateUserProfile(clientAccountUpdateModel, UserId); if (result) { return(Ok()); } else { return(NotFound()); } }