Пример #1
0
        protected override async Task OnInitializedAsync()
        {
            var myDog = await Client.GetDefaultDog();

            DogModel       = new DogModel(myDog);
            IncidentModels = await Client.GetAllIncident();

            IncidentModels         = IncidentModels.OrderByDescending(x => x.IncidentDate).ToList();
            DialogService.OnClose += (res) => Close(res);
        }
Пример #2
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);
            }
        }
Пример #3
0
        public async Task DeleteData()
        {
            var result = await Client.DeleteIncident(new IncidentDeleteRequest()
            {
                IncidentId = Model.IncidentId
            });

            if (result.IsSuccessStatusCode)
            {
                NotificationService.Notify(NotificationSeverity.Success, "Deleted successfully");
                ShowEditData   = false;
                IncidentModels = await Client.GetAllIncident();

                IncidentModels = IncidentModels.OrderByDescending(x => x.IncidentDate).ToList();
                StateHasChanged();
            }
            else
            {
                NotificationService.Notify(NotificationSeverity.Error, "Failed", result.ReasonPhrase, 6000);
            }
        }