Exemplo n.º 1
0
        public async Task <HttpResponseMessage> UpdateTreatment(TreatmentUpdateRequest 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 serialized    = System.Text.Json.JsonSerializer.Serialize(request);
            var stringContent = new StringContent(serialized, Encoding.UTF8, "application/json");
            var result        = await client.PostAsync($"/Treatment/update", stringContent);

            return(result);
        }
Exemplo n.º 2
0
        public async Task HandleValidSubmit()
        {
            HttpResponseMessage result = null;

            if (Model.TreatmentId == null || Model.TreatmentId.Value == 0)
            {
                var request = new TreatmentCreateRequest();
                request.Treatment.Created            = Model.Created;
                request.Treatment.Modified           = DateTime.UtcNow;
                request.Treatment.Dog                = DogModel;
                request.Treatment.Title              = Model.Title;
                request.Treatment.Doctor             = Model.Doctor;
                request.Treatment.ReceivedDateTime   = Model.ReceivedDateTime;
                request.Treatment.Comments           = Model.Comments;
                request.Treatment.Amount             = Model.Amount;
                request.Treatment.ExpirationDateTime = Model.ExpirationDateTime;
                result = await Client.CreateTreatment(request);
            }
            else
            {
                var request = new TreatmentUpdateRequest();
                request.Treatment.TreatmentId        = Model.TreatmentId;
                request.Treatment.Title              = Model.Title;
                request.Treatment.Doctor             = Model.Doctor;
                request.Treatment.ReceivedDateTime   = Model.ReceivedDateTime;
                request.Treatment.Comments           = Model.Comments;
                request.Treatment.Amount             = Model.Amount;
                request.Treatment.ExpirationDateTime = Model.ExpirationDateTime;
                request.Treatment.Deleted            = Model.Deleted;
                request.Treatment.Created            = Model.Created;
                request.Treatment.Modified           = Model.Modified;
                request.Treatment.Dog = DogModel;
                result = await Client.UpdateTreatment(request);
            }
            if (result.IsSuccessStatusCode)
            {
                NotificationService.Notify(NotificationSeverity.Success, "Saved successfully");
                ShowEditData    = false;
                TreatmentModels = await Client.GetAllTreatments();

                StateHasChanged();
            }
            else
            {
                NotificationService.Notify(NotificationSeverity.Error, "Failed", result.ReasonPhrase, 6000);
            }
        }
Exemplo n.º 3
0
 public bool UpdateTreatment(TreatmentUpdateRequest request)
 {
     return(_treatmentsRepository.UpdateTreatment(request.Treatment));
 }
Exemplo n.º 4
0
 public bool Update([FromBody] TreatmentUpdateRequest request)
 {
     return(_treatmentManager.UpdateTreatment(request));
 }