public void UpdateUserDetails(UserDetailsUpdateModel updateModel) { try { int userId = updateModel.UserId; string birthDate = updateModel.BirthDate.ToString("yyyy-MM-dd"); string sex = updateModel.Sex; double height = updateModel.Height; double weight = updateModel.Weight; double bmr = updateModel.Bmr; string activityLevel = updateModel.ActivityLevel; double tdee = updateModel.Tdee; double goalWeight = updateModel.GoalWeight; string weightGoalTimeline = updateModel.WeightGoalTimeline; string sql = $"call update_user({userId},'{birthDate}','{sex}',{height},{weight},{bmr},'{activityLevel}',{tdee},{goalWeight},'{weightGoalTimeline}')"; using (var connection = _dbConnectionFactory.CreateConnection(ConfigurationsHelper.ConnectionString)) { connection.Open(); connection.Execute(sql); } } catch (Exception e) { throw e; } }
public IActionResult UpdateUserDetails(int id, [FromBody] UserDetailsUpdateModel updateModel) { updateModel.UserId = id; UpdateUserDetailsResponse response = _userService.UpdateUserDetails(updateModel); if (!response.ResponseStatus.HasError()) { return(Ok()); } return(StatusCode(response.ResponseStatus.Status, response.ResponseStatus.Message)); }
public UpdateUserDetailsResponse UpdateUserDetails(UserDetailsUpdateModel updateModel) { UpdateUserDetailsResponse response = new UpdateUserDetailsResponse(); //TODO: Handle with non existent user id try { _userRepository.UpdateUserDetails(updateModel); response.ResponseStatus.SetOk(); } catch (Exception e) { _logger.LogError(e.ToString()); response.ResponseStatus.SetError(ResponseStatusCode.INTERNAL_SERVER_ERROR, e.ToString()); } return(response); }