Esempio n. 1
0
        private async void KegsCommandRecieverAsync()
        {
            try
            {
                await _navigationService.GoBackAsync(animated : false);

                KegHasAlert = false;
                Alerts      = null;
                MaintenanceCollection.Clear();
                RemoveMaintenanceCollection.Clear();
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Esempio n. 2
0
        private async void AddAlertCommandRecieverAsync()
        {
            if (SelectedMaintenance != null)
            {
                List <long> neededTypes = MaintenanceCollection.Where(x => x.Id == SelectedMaintenance.Id).Select(x => x.Id).ToList();
                var         model       = new AddMaintenanceAlertRequestModel
                {
                    AlertCc      = "",
                    DueDate      = SelectedMaintenance.DueDate,
                    KegId        = KegId,
                    Message      = SelectedMaintenance.Message,
                    NeededTypes  = neededTypes,
                    ReminderDays = 5
                };

                try
                {
                    Loader.StartLoading();
                    var result = await _dashboardService.PostMaintenanceAlertAsync(model, AppSettings.SessionId, Configuration.PostedMaintenanceAlert);

                    if (result.Response.StatusCode == System.Net.HttpStatusCode.OK.ToString())
                    {
                        await _dialogService.DisplayAlertAsync("Alert", "Alert adedd successfuly", "Ok");

                        foreach (var item in result.AddMaintenanceAlertResponseModel)
                        {
                            var removal = MaintenanceCollection.Where(x => x.Id == item.MaintenanceType.Id).FirstOrDefault();
                            if (removal != null)
                            {
                                MaintenanceCollection.Remove(removal);
                                RemoveMaintenanceCollection.Add(removal);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
                finally
                {
                    Loader.StopLoading();
                    SelectedMaintenance = null;
                }
            }
        }
Esempio n. 3
0
        private async void RemoveAlertCommandRecieverAsync()
        {
            if (RemoveSelecetedMaintenance != null)
            {
                var neededTypes = RemoveMaintenanceCollection.Where(x => x.Id == RemoveSelecetedMaintenance.Id).Select(x => x.Id).FirstOrDefault();
                Loader.StartLoading();
                var model = new DeleteMaintenanceAlertRequestModel
                {
                    KegId  = KegId,
                    TypeId = neededTypes,
                };
                try
                {
                    var result = await _dashboardService.PostMaintenanceDeleteAlertUrlAsync(model, AppSettings.SessionId, Configuration.DeleteTypeMaintenanceAlert);

                    if (result.Response.StatusCode == System.Net.HttpStatusCode.OK.ToString())
                    {
                        Loader.StopLoading();
                        await _dialogService.DisplayAlertAsync("Alert", "Alert removed successfuly", "Ok");

                        foreach (var item in result.AddMaintenanceAlertResponseModel)
                        {
                            var removedItem = RemoveMaintenanceCollection.Where(x => x.Id != item.MaintenanceType.Id).First();
                            if (removedItem != null)
                            {
                                RemoveMaintenanceCollection.Remove(removedItem);
                                MaintenanceCollection.Add(removedItem);
                            }
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
                finally
                {
                    Loader.StopLoading();
                    RemoveSelecetedMaintenance = null;
                }
            }
        }