예제 #1
0
        public async Task HandleValidSubmit()
        {
            HttpResponseMessage result = null;

            if (Model.IncidentId == null || Model.IncidentId.Value == 0)
            {
                var request = new IncidentCreateRequest();
                request.Incident.Created      = Model.Created;
                request.Incident.Modified     = DateTime.UtcNow;
                request.Incident.Dog          = DogModel;
                request.Incident.Title        = Model.Title;
                request.Incident.Description  = Model.Description;
                request.Incident.IncidentDate = Model.IncidentDate;
                request.Incident.IncidentType = Model.IncidentType;
                result = await Client.CreateIncident(request);
            }
            else
            {
                var request = new IncidentUpdateRequest();
                request.Incident.IncidentId   = Model.IncidentId;
                request.Incident.Deleted      = Model.Deleted;
                request.Incident.Created      = Model.Created;
                request.Incident.Modified     = Model.Modified;
                request.Incident.Dog          = DogModel;
                request.Incident.Title        = Model.Title;
                request.Incident.Description  = Model.Description;
                request.Incident.IncidentDate = Model.IncidentDate;
                request.Incident.IncidentType = Model.IncidentType;
                result = await Client.UpdateIncident(request);
            }
            if (result.IsSuccessStatusCode)
            {
                NotificationService.Notify(NotificationSeverity.Success, "Saved successfully");
                ShowEditData   = false;
                IncidentModels = await Client.GetAllIncident();

                IncidentModels = IncidentModels.OrderByDescending(x => x.IncidentDate).ToList();
                StateHasChanged();
            }
            else
            {
                NotificationService.Notify(NotificationSeverity.Error, "Failed", result.ReasonPhrase, 6000);
            }
        }
예제 #2
0
        public async Task <HttpResponseMessage> CreateIncident(IncidentCreateRequest 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 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($"/Incident/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);
        }
예제 #3
0
 public bool Add([FromBody] IncidentCreateRequest request)
 {
     return(_incidentManager.CreateNewIncident(request));
 }
예제 #4
0
 public bool CreateNewIncident(IncidentCreateRequest request)
 {
     return(_incidentRepository.CreateIncident(request.Incident));
 }