Exemple #1
0
 public async Task DeleteResult(ResultsForViewDto result)
 {
     try
     {
         var deletedResult = await _apiService.DeleteJsonAsync <ResultsForViewDto>(_url, new { Id = result.Id });
     }
     catch
     {
         _notification.Error("Something went wrong");
     }
 }
        public async Task <Event> AddEvent(DataForAddingEventDto newEvent)
        {
            if (newEvent.Icon.Data == null)
            {
                _notification.Error("Icon Should not be null");
                throw new Exception("Icon Should not be null");
            }

            var content         = GetFormDataContent(newEvent);
            var eventFromServer = await _apiService.PostFormAsync <Event>("/events/api/events", content);

            newEvent.Icon.Data?.Dispose();

            return(eventFromServer);
        }
 public async Task UpdateEventHead(EventHead eventHead)
 {
     try
     {
         await _apiService.PutJsonAsync(Url, eventHead);
     }
     catch
     {
         _notification.Error("Something went wrong");
     }
 }
Exemple #4
0
 private void ShowNotification(HttpMethod method, HttpStatusCode responseStatus)
 {
     if (responseStatus == HttpStatusCode.OK)
     {
         string message = null;
         if (method == HttpMethod.Post)
         {
             message = "Successfully added";
         }
         else if (method == HttpMethod.Put)
         {
             message = "Successfully updated";
         }
         else if (method == HttpMethod.Delete)
         {
             message = "Successfully deleted";
         }
         else
         {
             return;
         }
         _notification.Success(message);
     }
     else if (responseStatus == HttpStatusCode.Forbidden)
     {
         _notification.Warning("You don't have permission to do that");
     }
     else
     {
         string message = null;
         if (method == HttpMethod.Get)
         {
             message = "Failed to fetch data";
         }
         if (method == HttpMethod.Post)
         {
             message = "Failed to add data";
         }
         else if (method == HttpMethod.Put)
         {
             message = "Failed to update data";
         }
         else if (method == HttpMethod.Delete)
         {
             message = "Failed to delete data";
         }
         else
         {
             return;
         }
         _notification.Error(message);
     }
 }
Exemple #5
0
        public async Task DeleteHighlight(Highlight highlight)
        {
            try
            {
                var deletedHighlight =
                    await _apiService.DeleteJsonAsync <Highlight>(_url, new { Id = highlight.Id, Name = highlight.Name });

                var highlights = await _state.GetHighlights();

                var highlightInState = highlights.FirstOrDefault(x => x.Id == deletedHighlight.Id);
                highlights.Remove(highlightInState);
            }
            catch
            {
                _notification.Error("Something went wrong");
            }
        }