Exemplo n.º 1
0
        async void ExecuteConfirmReport()
        {
            loadingService.Show();

            using (var unitOfWork = new UnitOfWork(new ESFContext()))
            {
                var newReport = new ReportModel()
                {
                    UserId  = userService.User.Id,
                    Date    = DateTime.Today.Date,
                    Weight  = Weight,
                    Version = 0,
                };
                unitOfWork.Reports.Add(newReport);
                await unitOfWork.Complete();

                foreach (var debris in MapDebrisCollection)
                {
                    var newDebris = new DebrisModel()
                    {
                        Latitude   = debris.Latitude,
                        Longitude  = debris.Longitude,
                        DebrisType = debris.DebrisType,
                        ReportId   = newReport.Id,
                    };
                    unitOfWork.Debris.Add(newDebris);
                }
                await unitOfWork.Complete();
            }

            loadingService.Hide();

            await navigationService.GoBackAsync();
        }
Exemplo n.º 2
0
        async void ExecuteLoginAttempt()
        {
            loadingService.Show();

            if (await _userService.LoginAttempt(Login, Password))
            {
                await _navigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(HomePage)}");
            }
            else
            {
                _pageDialogService.DisplayAlertAsync("Alerta", "Tentativa de login não funcionou!", "Tentar novamente");
            }

            loadingService.Hide();
        }
        public static void WithExecute(
            this ILoadingService loadingService,
            string message,
            Action execute)
        {
            try
            {
                loadingService.Show(message);

                execute();
            }
            finally
            {
                loadingService.Hide();
            }
        }
        public static async Task <TResult> WithExecuteAsync <TResult>(
            this ILoadingService loadingService,
            string message,
            Func <Task <TResult> > execute)
        {
            try
            {
                loadingService.Show(message);

                return(await execute());
            }
            finally
            {
                loadingService.Hide();
            }
        }
        public static async Task WithExecuteAsync(
            this ILoadingService loadingService,
            string message,
            Func <Task> execute)
        {
            try
            {
                loadingService.Show(message);

                await execute();
            }
            finally
            {
                loadingService.Hide();
            }
        }
        public static TResult WithExecute <TResult>(
            this ILoadingService loadingService,
            string message,
            Func <TResult> execute)
        {
            try
            {
                loadingService.Show(message);

                return(execute());
            }
            finally
            {
                loadingService.Hide();
            }
        }