public async Task <ApiResult <List <AdminAlertListDto> > > UpdateAlert(AdminAlertListDto dto)
        {
            var response = await _http.PostAsJsonAsync($"{Constants.ControllerNames.Alerts}/{Constants.Routes.Update}/{Constants.RoleNames.Admin}", dto);

            if (!response.IsSuccessStatusCode)
            {
                return(new ApiResult <List <AdminAlertListDto> >
                {
                    Successful = false,
                    Error = "Something went wrong when trying to communicate with the server."
                });
            }

            return(await response.Content.ReadFromJsonAsync <ApiResult <List <AdminAlertListDto> > >());
        }
Example #2
0
        public async Task <ApiResult <List <AdminAlertListDto> > > UpdateAlert(AdminAlertListDto dto)
        {
            try
            {
                var alert = _context.ApplicationAlerts.FirstOrDefault(a => a.Id == dto.Id);

                alert.Read        = dto.Read;
                alert.AddressedBy = dto.AddressedBy;
                alert.Archived    = dto.Archived;
                _context.Alerts.Update(alert);
                await _context.SaveChangesAsync();

                return(GetAdminAlerts());
            }
            catch (Exception ex)
            {
                _logger.LogError("An error occured when trying to updating alerts to the database:\n" + ex.Message);
                return(new ApiResult <List <AdminAlertListDto> >
                {
                    Successful = false,
                    Error = "An error occured when trying to update alerts to the database."
                });
            }
        }
Example #3
0
 public IActionResult UpdateAdminAlerts([FromBody] AdminAlertListDto dto)
 {
     return(new ObjectResult(_alertService.UpdateAlert(dto)));
 }
Example #4
0
 protected async Task DeleteAlert(AdminAlertListDto alert)
 {
     alert.Archived = true;
     //alert.AddressedBy =
     await _alertService.UpdateAlert(alert);
 }