public async Task <ValidationOutputDto> ValidateUpdateInput(UpdateSchedulerInputDto request) { if (string.IsNullOrEmpty(request.FirstName)) { return new ValidationOutputDto { IsSuccess = false, StatusCode = 400, Message = "FirstName is a required field." } } ; if (string.IsNullOrEmpty(request.LastName)) { return new ValidationOutputDto { IsSuccess = false, StatusCode = 400, Message = "LastName is a required field." } } ; return(new ValidationOutputDto { IsSuccess = true, StatusCode = 200, Message = string.Empty }); }
public async Task <IActionResult> UpdateScheduler([FromBody] UpdateSchedulerInputDto request) { try { var scheduler = await _schedulerService.GetSchedulerById(request.id); if (scheduler == null) { return(BadRequest(new ApiResponse(400, "Scheduler is not existing."))); } var validationResponse = await _schedulerService.ValidateUpdateInput(request); if (!validationResponse.IsSuccess) { return(BadRequest(new ApiResponse(validationResponse.StatusCode, validationResponse.Message))); } scheduler.FirstName = request.FirstName; scheduler.LastName = request.LastName; scheduler.JobTitle = request.JobTitle; scheduler.Company = request.Company; scheduler.Industry = request.Industry; scheduler.City = request.City; scheduler.State = request.State; scheduler.LinkedInUrl = request.LinkedInUrl; scheduler.ConnectionRequest = request.ConnectionRequest; scheduler.Date = request.Date; scheduler.RequestAccepted = request.RequestAccepted; scheduler.IsMessage1 = request.IsMessage1; scheduler.DateMessage1 = request.DateMessage1; scheduler.IsMessage2 = request.IsMessage2; scheduler.DateMessage2 = request.DateMessage2; scheduler.IsMessage3 = request.IsMessage3; scheduler.DateMessage3 = request.DateMessage3; scheduler.IsMessage4 = request.IsMessage4; scheduler.DateMessage4 = request.DateMessage4; scheduler.IsMessage5 = request.IsMessage5; scheduler.DateMessage5 = request.DateMessage5; scheduler.Neutral = request.Neutral; scheduler.Negative = request.Negative; await _schedulerService.UpdateScheduler(scheduler); return(Ok(new ApiResponse(200, "Success"))); } catch (Exception x) { return(BadRequest(new ApiResponse(400, "Something went wrong."))); } }