private async void OnConfirm()
        {
            if (this.File == null)
            {
                return;
            }

            if (this.ImageExtensions.Contains(this.File.Type))
            {
                try
                {
                    await using var stream = new MemoryStream();
                    await this.File.WriteToStreamAsync(stream);

                    if (await this.UserService.UpdateProfileImage(stream.ToArray()))
                    {
                        this.ModalService.Close(ModalResult.Ok <bool>(true));
                        ((ModalService)this.ModalService).OnConfirm -= this.OnConfirm;
                    }
                }
                catch (Exception e)
                {
                    this.Toaster.Add("Problem during the image uploading. Please try again later.", MatToastType.Danger,
                                     "My Profile Error");
                    Console.WriteLine(e);
                }
            }
            else
            {
                this.Toaster.Add("Invalid file extension. Please try again with a correct type.", MatToastType.Danger,
                                 "My Profile Error");
            }
        }
Пример #2
0
        public async Task CreateNewEmployee()
        {
            var authState = await authenticationStateTask;
            int UserId    = 0;

            if (authState.User.Identity.IsAuthenticated)
            {
                var User = await UserManager.GetUserAsync(authState.User);

                UserId = User.Id;
            }

            var user = new Employee
            {
                FirstName    = Input.FirstName,
                LastName     = Input.LastName,
                Email        = Input.Email,
                PhoneNumber  = Input.PhoneNumber,
                Location     = Input.Location,
                FranchiseeId = UserId,
                StoreId      = Input.StoreId
            };
            IdentityResult result = await UserManager.CreateAsync(user, Input.Password);

            if (result.Succeeded)
            {
                Logger.LogInformation("Franchisee created a new account with password.");

                await EmailManager.SendConfirmationEmailAsync(user);
            }

            await BlazoredModal.Close(ModalResult.Ok(true));
        }
        public void SubmitForm()
        {
            var newDate = new DateTime(Booking2Change.BookingTime.Year, Booking2Change.BookingTime.Month, Booking2Change.BookingTime.Day, Time.Hour, Time.Minute, 0);

            Booking2Change.BookingTime = newDate;
            BlazoredModal?.Close(ModalResult.Ok(Booking2Change));
        }
Пример #4
0
        private async void SaveChanges()
        {
            bool confirmed = await JsRunTime.InvokeAsync <bool>("confirm", "Are you sure you want to save changes?");

            if (confirmed)
            {
                FormatRunTimeFields();

                try
                {
                    await RunTimeParameterService.UpdateRunTimesForJob(results);

                    Toaster.Add("Run Time Changes Saved Successfully", MatToastType.Success, "Success", "✓");

                    await GetData();

                    Modal.Close(ModalResult.Ok(results));
                }
                catch (Exception ex)
                {
                    Toaster.Add("Error Saving Run Time Changes, try again.", MatToastType.Danger, "Warning", "⚠");
                    Console.WriteLine("Error saving run time changes", ex.Message);
                }
            }
        }
Пример #5
0
 public async void Save()
 {
     Product.UnitQuantity     = NewProductQuantity.UnitQuantityTypeVolume;
     Product.UnitQuantityType = NewProductQuantity.MeasurementType;
     //await ProductService.AddProduct(Product);
     await BlazoredModal.CloseAsync(ModalResult.Ok(Product));
 }
Пример #6
0
        public async Task FormSubmitted()
        {
            var model = Converter.Convert(View);
            await Repository.Insert(model);

            await BlazoredModal.CloseAsync(ModalResult.Ok <TModel>(model));
        }
        async Task SendEmailAsync()
        {
            if (string.IsNullOrEmpty(ToAddress))
            {
                Message = "Please set a to address and try again ";
                return;
            }
            Email email = new Email();

            email.Subject   = Subject;
            email.ToAddress = ToAddress;
            if (Environment.MachineName == "DESKTOP-UROO8T1" || User.Identity.Name.ToLower() == "*****@*****.**")
            {
                email.ToAddress = "*****@*****.**";
            }
            if (!string.IsNullOrEmpty(EditorContent))
            {
                email.Body = await this.QuillHtml.GetHTML();
            }
            email.Body = $"{email.Body}<br>{EditorContentHtmlSuffix}";
            var response = await EmailService.SendEmailAsync(email);

            if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
            {
                ToastService.ShowSuccess($"Email appears to have been sent correctly to {email.ToAddress}", "SUCCESS");
                await ModalInstance.CloseAsync(ModalResult.Ok <string>(Message));
            }
            else
            {
                ToastService.ShowError($"Email failed to send with the following status code {response.StatusCode}", "ERROR");
            }
        }
Пример #8
0
 private async void DeleteField()
 {
     if (await this.WorkingFieldService.Delete(this.Id))
     {
         this.ModalService.Close(ModalResult.Ok <bool>(true));
     }
 }
Пример #9
0
        protected async Task ClockIn()
        {
            timeEntryValidator.ClearErrors();

            var errors = new Dictionary <string, List <string> >();

            if (ClockInEntry.PositionId == 0)
            {
                errors.Add(nameof(TimeEntry.PositionId), new List <string>()
                {
                    "A position must be selected."
                });
            }
            if (ClockInEntry.MemberId == 0)
            {
                errors.Add(nameof(TimeEntry.MemberId), new List <string>()
                {
                    "A member must be selected"
                });
            }

            if (errors.Count() > 0)
            {
                timeEntryValidator.DisplayErrors(errors);
            }
            else
            {
                ClockInEntry.StartTime = DateTime.Now;
                var result = await TSService.PunchClock(ClockInEntry);

                await Modal.CloseAsync(ModalResult.Ok(result));
            }
        }
Пример #10
0
        protected async Task FormSubmitted()
        {
            var model = Converter.Convert(View);
            await repository.Update(Id, model);

            await BlazoredModal.CloseAsync(ModalResult.Ok <TModel>(model));
        }
Пример #11
0
        public async Task StartRaffleWithoutEntrants()
        {
            await RaffleService.StartRaffle(false);

            Modal.Close(ModalResult.Ok(this));
            StateHasChanged();
        }
 private async void OnConfirm()
 {
     if (await this.MovieService.UpdateSeenStatuses(this.SaveList))
     {
         this.ModalService.Close(ModalResult.Ok(true));
         ((ModalService)this.ModalService).OnConfirm -= this.OnConfirm;
     }
 }
Пример #13
0
        protected override async Task <Contact> ValidSubmitAsync()
        {
            Contact result = await base.ValidSubmitAsync();

            ModalService.Close(ModalResult.Ok(result));

            return(result);
        }
Пример #14
0
        protected async Task HandleValidSubmit()
        {
            await EmployeeDataService.AddEmployee(Employee);

            await ModalInstance.CloseAsync(ModalResult.Ok(true));

            ToastService.ShowSuccess($"{Employee.FullName} Added successfully.", "Success");
        }
Пример #15
0
        protected async Task HandleValidSubmit()
        {
            await TaskDataService.AddTask(Task);

            await ModalInstance.CloseAsync(ModalResult.Ok(true));

            ToastService.ShowSuccess($"{Task.Title} Added successfully.", "Success");
        }
Пример #16
0
        private async void DeleteDialogClosed(ModalResult modalResult)
        {
            if (!modalResult.Cancelled && (bool)modalResult.Data && await this.WorkingFieldService.Delete(this.Id))
            {
                this.ModalService.Close(ModalResult.Ok <bool>(true));
            }

            this.ModalService.OnClose -= this.DeleteDialogClosed;
        }
Пример #17
0
 protected void Submit()
 {
     if (_editContext.Validate())
     {
         UserRepository.Save(MobileSubscription);
         ToastService.ShowSuccess("Abonnement toegevoegd.");
         BlazoredModal.Close(ModalResult.Ok <MobileSubscription>(MobileSubscription));
     }
 }
Пример #18
0
        protected async Task DeleteConfirm()
        {
            var result = await TableService.Delete(Table.Id);

            if (result.Successful)
            {
                BlazoredModal.Close(ModalResult.Ok(true));
            }
        }
Пример #19
0
        private async void Finish()
        {
            await JSRuntime.InvokeVoidAsync("stopScanner");

            await BlazoredModal.CloseAsync(ModalResult.Ok(new BarcodeResult
            {
                Barcode = BarcodeValue
            }));
        }
        protected async void OnConfirm()
        {
            bool isValid = this.Context.Validate();

            if (isValid && await this.UserService.UpdateUsername(this.UsernameUpdate))
            {
                this.ModalService.Close(ModalResult.Ok <bool>(true));
                ((ModalService)this.ModalService).OnConfirm -= this.OnConfirm;
            }
        }
        protected async void OnConfirm()
        {
            bool isValid = this.Context.Validate();

            if (isValid && await this.FriendService.SendFriendRequest(this.Model))
            {
                this.ModalService.Close(ModalResult.Ok <bool>(true));
                ((ModalService)this.ModalService).OnConfirm -= this.OnConfirm;
            }
        }
Пример #22
0
        protected async Task Submit()
        {
            var options = new JsonSerializerOptions {
                Converters = { new HardwareConverter() }
            };

            await HttpClient.PutAsJsonAsync("api/hardware", Command, options);

            await BlazoredModal.CloseAsync(ModalResult.Ok(Hardware.Id));
        }
Пример #23
0
        private Task SubmitVoteAsync(string vote)
        {
            if (string.IsNullOrWhiteSpace(vote))
            {
                return(Task.CompletedTask);
            }

            BlazoredModal.Close(ModalResult.Ok(vote, typeof(string)));

            return(Task.CompletedTask);
        }
Пример #24
0
        private async Task Delete()
        {
            var confirmResult = await this.Context.ModalDialog.ShowMessageAsync("Delete Booking", "Are you sure you want to delete this booking?", MessageDialogOptions.ConfirmCancel);

            if (confirmResult.Cancelled)
            {
                return;
            }

            this.Close(ModalResult.Ok(true));
        }
Пример #25
0
        private async void OnConfirm()
        {
            var indexList = this.List.Where(x => x.IsSelected).Select(x => x.Id).ToList();

            if (await this.SeriesService.UpdateCategories(this.SeriesId, new SeriesCategoryUpdateModel {
                Ids = indexList
            }))
            {
                this.ModalService.Close(ModalResult.Ok(true));
                ((ModalService)this.ModalService).OnConfirm -= this.OnConfirm;
            }
        }
        private async void OnConfirm()
        {
            var indexList = this.List.Where(x => x.IsMine).Select(x => x.Id).ToList();

            if (await this.MovieService.UpdateMyMovies(new MyMovieModel {
                Ids = indexList
            }))
            {
                this.ModalService.Close(ModalResult.Ok(true));
                ((ModalService)this.ModalService).OnConfirm -= this.OnConfirm;
            }
        }
Пример #27
0
        protected async Task SaveOriginAsync()
        {
            var isNewOrigin = Origin.OriginId == 0;

            if (isNewOrigin)
            {
                Origin.DateCreated = DateTime.UtcNow;
            }
            else
            {
                Origin.DateModified = DateTime.UtcNow;
            }

            if (!string.IsNullOrEmpty(OriginUri))
            {
                Origin.Uri = new Uri(OriginUri);
            }

            Origin.ParentOrigin = SelectedParentOrigin;
            Origin.CreatedBy ??= UserId;
            Origin.ModifiedBy = UserId;

            if (Origin.Location != null)
            {
                if (Origin.Location.IsNotEmpty())
                {
                    if (Origin.Location.LocationId == 0)
                    {
                        Origin.Location.DateCreated = DateTime.UtcNow;
                    }
                    else
                    {
                        Origin.Location.DateModified = DateTime.UtcNow;
                    }
                }
                else
                {
                    Origin.Location = null;
                }
            }

            Origin = await ApiClient.PutOriginAsync(Origin);

            if (BlazoredModal != null)
            {
                await BlazoredModal.Close(ModalResult.Ok(Origin));
            }
            else
            {
                await CancelAsync(isNewOrigin);
            }
        }
 public async void HandleValidSubmit()
 {
     if (Agency.Id == 0 && await _agencyService.AddAgency(Agency))
     {
         _toastService.ShowSuccess("Agence ajoutée avec succès");
         await BlazoredModal.Close(ModalResult.Ok(Agency));
     }
     else if (Agency.Id > 0 && await _agencyService.UpdateAgency(Agency))
     {
         _toastService.ShowSuccess("Agence enregistrée avec succès");
         await BlazoredModal.Close(ModalResult.Ok(Agency));
     }
 }
Пример #29
0
        protected async Task LogIn()
        {
            var result = await AccountService.Login(User);

            if (result.Successful)
            {
                BlazoredModal.Close(ModalResult.Ok(true));
            }
            else
            {
                ErrorMessage = result.Error;
            }
        }
Пример #30
0
        private async void OnConfirm()
        {
            bool isValid = this.Context.Validate();

            if (this.IsEdit)
            {
                if (isValid && await this.EpisodeService.UpdateShort(this.Id, this.Model))
                {
                    this.ModalService.Close(ModalResult.Ok(true));
                    ((ModalService)this.ModalService).OnConfirm -= this.OnConfirm;
                }
            }
        }