public async Task HandleValidSubmit() { HttpResponseMessage result = null; if (Model.BoardingId == null || Model.BoardingId.Value == 0) { var request = new BoardingCreateRequest(); request.Boarding.Created = Model.Created; request.Boarding.Modified = DateTime.UtcNow; request.Boarding.Dog = DogModel; request.Boarding.PaymentAmount = Model.PaymentAmount; request.Boarding.Comments = Model.Comments; request.Boarding.Company = Model.Company; request.Boarding.Address = Model.Address; request.Boarding.Reason = Model.Reason; request.Boarding.StartDateTime = Model.StartDateTime; request.Boarding.EndDateTime = Model.EndDateTime; request.Boarding.Website = Model.Website; result = await Client.CreateBoarding(request); } else { var request = new BoardingUpdateRequest(); request.Boarding.BoardingId = Model.BoardingId; request.Boarding.PaymentAmount = Model.PaymentAmount; request.Boarding.Comments = Model.Comments; request.Boarding.Company = Model.Company; request.Boarding.Address = Model.Address; request.Boarding.Reason = Model.Reason; request.Boarding.StartDateTime = Model.StartDateTime; request.Boarding.EndDateTime = Model.EndDateTime; request.Boarding.Deleted = Model.Deleted; request.Boarding.Created = Model.Created; request.Boarding.Modified = Model.Modified; request.Boarding.Dog = DogModel; request.Boarding.Website = Model.Website; result = await Client.UpdateBoarding(request); } if (result.IsSuccessStatusCode) { NotificationService.Notify(NotificationSeverity.Success, "Saved successfully"); ShowEditData = false; BoardingModels = await Client.GetAllBoarding(); StateHasChanged(); } else { NotificationService.Notify(NotificationSeverity.Error, "Failed", result.ReasonPhrase, 6000); } }
public async Task <HttpResponseMessage> CreateBoarding(BoardingCreateRequest request) { Logger.LogInformation("Creating Health with request"); client.DefaultRequestHeaders.Add("Access-Control-Allow-Origin", "*"); client.DefaultRequestHeaders.Add("Access-Control-Allow-Credentials", "true"); client.DefaultRequestHeaders.Add("Access-Control-Allow-Headers", "Access-Control-Allow-Origin,Content-Type"); //var postRequest = JsonSerializer.Serialize<DogUpdateRequest>(request); var serialized = System.Text.Json.JsonSerializer.Serialize(request); //JsonConvert.SerializeObject(request); var stringContent = new StringContent(serialized, Encoding.UTF8, "application/json"); //var addItem = new { Name = "Test" }; Logger.LogInformation("Creating Health with request 1"); var result = await client.PostAsync($"/Boarding/add", stringContent); var postContent = await result.Content.ReadAsStringAsync(); Logger.LogInformation("Creating Health got result: " + postContent); Logger.LogInformation("Creating Health is success: " + result.IsSuccessStatusCode); return(result); }
public bool Add([FromBody] BoardingCreateRequest request) { return(_boardingManager.CreateNewBoarding(request)); }
public bool CreateNewBoarding(BoardingCreateRequest request) { return(_boardingRepository.CreateBoarding(request.Boarding)); }