예제 #1
0
        private void getUsersTask(Panel TaskContent, Guid guid)
        {
            var userTaskBusinessObj = new BusinessLayer.UsersTaskBusinessObjects();

            _userTask = userTaskBusinessObj.GetAUserTaskById(guid);


            getUserInfo((Guid)_userTask.userId, TaskContent);
        }
        public async Task <UsersTask> Get(int id)
        {
            UsersTask result = null;

            using (var ctx = new BugTrackingContext())
            {
                _logger.Debug("Get(). Getting task by id: {0}.", id);
                result = await ctx.UsersTasks.Include(u => u.Project).Include(u => u.User).FirstOrDefaultAsync(p => p.Id == id);
            }
            _logger.Debug("Get(). Task Name = {0} have get.", result.Topic);
            return(result);
        }
        public async Task <UsersTask> Update(UsersTask usersTask)
        {
            using (var ctx = new BugTrackingContext())
            {
                _logger.Debug("Update(). Updating task: {0}.", usersTask.Topic);
                ctx.Entry(usersTask).State = EntityState.Modified;
                await ctx.SaveChangesAsync();

                _logger.Debug("Update(). Task {0} have updated.", usersTask.Topic);
            }

            return(usersTask);
        }
        public async Task <UsersTask> Add(UsersTask usersTask)
        {
            UsersTask result = null;

            using (var ctx = new BugTrackingContext())
            {
                _logger.Debug("Add(). Adding task {0}.", usersTask.Topic);
                result = ctx.UsersTasks.Add(usersTask);
                await ctx.SaveChangesAsync();

                _logger.Debug("Add(). Task {0} have added.", usersTask.Topic);
            }

            return(result);
        }
예제 #5
0
        public async Task <IActionResult> OnPost()
        {
            // Check if the provided model isn't valid.
            if (!ModelState.IsValid)
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, "An error has been encountered. Please check again the input fields.");
                // Redisplay the page.
                return(Page());
            }
            // Define a new task.
            var task = new UsersTask
            {
                Items = new List <UserInputModel>
                {
                    new UserInputModel
                    {
                        Email          = Input.Email,
                        Type           = "Password",
                        Data           = JsonSerializer.Serialize(Input.Password),
                        EmailConfirmed = Input.EmailConfirmed
                    }
                }
            };

            // Try to run the task.
            try
            {
                // Run the task.
                await task.CreateAsync(_serviceProvider, CancellationToken.None);
            }
            catch (Exception exception)
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, exception.Message);
                // Redisplay the page.
                return(Page());
            }
            // Display a message.
            TempData["StatusMessage"] = "Success: 1 user created successfully.";
            // Redirect to the index page.
            return(RedirectToPage("/Administration/Accounts/Users/Index"));
        }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        int SchoolID = info.getId();

        if (btnAdd.Text == "تسجيل الوارد")
        {
            Incoming inc = new Incoming();

            inc.Number = txtIncomingID.Text;
            //  inc.Date = Convert.ToDateTime(txtDate.Text);

            if (Calendar1.CultureName == "ar-SA")
            {
                inc.Date = MyDate.convertHijriToGregorian(txtDate.Text);
            }
            else
            {
                inc.Date = Convert.ToDateTime(txtDate.Text);
            }

            inc.Source     = int.Parse(ddlFrom.SelectedValue);
            inc.Subject    = txtSubject.Text;
            inc.SemesterId = MyDate.getCurrentSemesterId();
            inc.FileNumber = txtFileNumber.Text;
            inc.SchoolId   = SchoolID;
            inc.Type       = int.Parse(ddlType.SelectedValue);
            inc.Attachment = int.Parse(ddlFileAttach.SelectedValue);
            inc.IsDeleted  = false;


            var fileLocation = pdfFrame.Attributes["src"];
            ose.Incomings.Add(inc);
            ose.SaveChanges();

            if (!String.IsNullOrEmpty(fileLocation))
            {
                inc.FileLocation = fileLocation.Substring(2, fileLocation.Length - 2);

                var      path        = MapPath("~/");
                Document pdfDocument = new Document(path + "testImage.pdf");

                Resolution resolution = new Resolution(300);
                JpegDevice jpegDevice = new JpegDevice(resolution, 100);

                var x = pdfDocument.Pages.Count;

                for (int i = 1; i <= x; ++i)
                {
                    string filename = "images/Incomings/" + Guid.NewGuid() + ".jpg";
                    jpegDevice.Process(pdfDocument.Pages[i], path + filename);

                    IncomingsImage img = new IncomingsImage();
                    img.IncomingId = inc.Id;
                    img.Image      = filename;
                    ose.IncomingsImages.Add(img);
                }
            }

            ose.SaveChanges();

            /******************************************************************************************************************/
            List <Employee>      empLst = new List <Employee>();
            OnlineSchoolEntities km     = new OnlineSchoolEntities();

            if (RadioType.SelectedValue == "1")
            {
                empLst = (from k in km.Employees where k.SchoolId == SchoolID select k).ToList();
            }
            else
            if (RadioType.SelectedValue == "2")
            {
                foreach (ListViewItem item in LstJopEmployees.Items)
                {
                    CheckBox che = (CheckBox)item.FindControl("chkRow");
                    if (che.Checked)
                    {
                        var jobid = int.Parse(((HiddenField)item.FindControl("HiddenField2")).Value);

                        foreach (var emp in km.Employees)
                        {
                            if (emp.JobId == jobid && emp.SchoolId == SchoolID)
                            {
                                empLst.Add(emp);
                            }
                        }
                    }
                }

                foreach (ListViewItem item in LstEmp.Items)
                {
                    CheckBox che = (CheckBox)item.FindControl("chkRow");
                    if (che.Checked)
                    {
                        var userId = ((HiddenField)item.FindControl("HiddenField1")).Value;

                        empLst.Add((from k in km.Employees where k.IdentityNumber == userId select k).FirstOrDefault());
                    }
                }

                foreach (ListViewItem item in LstSpecification.Items)
                {
                    CheckBox che = (CheckBox)item.FindControl("chkRow");
                    if (che.Checked)
                    {
                        UsersTask ut            = new UsersTask();
                        string    specification = ((Label)item.FindControl("NameLabel")).Text;

                        foreach (Employee emp in km.Employees)
                        {
                            if (emp.Specification == specification && emp.SchoolId == SchoolID)
                            {
                                empLst.Add(emp);
                            }
                        }
                    }
                }
            }
            foreach (Employee emp in empLst.Distinct())
            {
                if (emp.SchoolId == SchoolID)
                {
                    UsersGeneralization userGeneralization = new UsersGeneralization();
                    userGeneralization.UserId     = emp.IdentityNumber;
                    userGeneralization.IncomingId = inc.Id;
                    userGeneralization.isSeen     = false;

                    km.UsersGeneralizations.Add(userGeneralization);
                    km.SaveChanges();
                    //    lblerror.Text = "تم الاضافة بنجاح";
                }
            }

            /*******************************************************************************************************************/

            //lblerror.Text = "تمت اضافة الوارد بنجاح";
            //IncId.Value = (inc.Id).ToString();
            // lnkTask.NavigateUrl = "~/Communication/TaskAdd.aspx?type=Incoming&typeId=" + inc.Id;
            ClientScript.RegisterStartupScript(this.GetType(), "openModal", "<script> openModal(); </script>", false);
            clear();
        }
        else
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            var c  = (from k in ose.Incomings where k.Id == id select k).FirstOrDefault();

            c.Number     = txtIncomingID.Text;
            c.FileNumber = txtFileNumber.Text;
            //   c.Date = Convert.ToDateTime(txtDate.Text);
            try
            {
                if (Calendar1.CultureName == "ar-SA")
                {
                    c.Date = MyDate.convertHijriToGregorian(txtDate.Text);
                }
                else
                {
                    c.Date = Convert.ToDateTime(txtDate.Text);
                }
            }catch (Exception ex)
            {
                txtDate.Text      = "";
                lblDateError.Text = "الرجاء ادخال تاريخ صحيح";
                return;
            }
            c.Source     = int.Parse(ddlFrom.SelectedValue);
            c.Subject    = txtSubject.Text;
            c.Type       = int.Parse(ddlType.SelectedValue);
            c.Attachment = int.Parse(ddlFileAttach.SelectedValue);

            var fileLocation = pdfFrame.Attributes["src"];
            if (!String.IsNullOrEmpty(fileLocation))
            {
                c.FileLocation = fileLocation.Substring(2, fileLocation.Length - 2);
            }
            ose.SaveChanges();
            //PlaceHolderSuccess.Visible = true;
            //lblerror.Text = "تم تعديل الوارد بنجاح";
            //IncId.Value = (c.Id).ToString();
            //  lnkTask.NavigateUrl = "~/Communication/TaskAdd.aspx?type=Incoming&typeId=" + c.Id;
            ClientScript.RegisterStartupScript(this.GetType(), "openModal", "<script> openModal(); </script>", false);
        }
    }
예제 #7
0
 public async Task <UsersTask> Update(UsersTask usersTask)
 {
     return(await _userTaskRepository.Update(usersTask));
 }
예제 #8
0
 public async Task <UsersTask> Add(UsersTask usersTask)
 {
     return(await _userTaskRepository.Add(usersTask));
 }
예제 #9
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Task task = new Task();

        task.Title  = txtTitle.Text;
        task.TypeId = Convert.ToInt32(ddlEventType.SelectedValue);

        if (!String.IsNullOrEmpty(txtLocationExecution.Text))
        {
            task.Location = txtLocationExecution.Text;
        }

        if (txtDate.Text != null && !string.IsNullOrEmpty(txtDate.Text.ToString()))
        {
            TimeSpan time = Convert.ToDateTime(txtTime.Text).TimeOfDay;

            if (CalendarDate.CultureName == "ar-SA")
            {
                task.Date = MyDate.convertHijriToGregorian(txtDate.Text).Add(time);
            }
            else
            {
                task.Date = DateTime.ParseExact(txtDate.Text, "yyyy/MM/dd", CultureInfo.CreateSpecificCulture("ar-EG")).Add(time);
            }
        }

        if (txtAlarmDate.Text != null && !string.IsNullOrEmpty(txtAlarmDate.Text.ToString()))
        {
            TimeSpan time = Convert.ToDateTime(txtAlarmTime.Text).TimeOfDay;

            if (CalendarDate.CultureName == "ar-SA")
            {
                task.DateAlarm = MyDate.convertHijriToGregorian(txtAlarmDate.Text).Add(time);
            }
            else
            {
                task.DateAlarm = DateTime.ParseExact(txtAlarmDate.Text, "yyyy/MM/dd", CultureInfo.CreateSpecificCulture("ar-EG")).Add(time);
            }
        }


        if (!String.IsNullOrEmpty(txtDescription.Text))
        {
            task.Description = txtDescription.Text;
        }

        if (ddlIncoming.SelectedValue != "-1")
        {
            task.IncommingId = int.Parse(ddlIncoming.SelectedValue);
        }

        if (ddlEmployee.SelectedValue != "-1")
        {
            task.EmployeeId = ddlEmployee.SelectedValue;
        }


        int schoolId = SchoolInfo.getId();

        task.SchoolId   = schoolId;
        task.SemesterId = MyDate.getCurrentSemesterId();

        task.IsStudentRequired  = chxStudent.Checked;
        task.IsEmployeeRequired = chxEmployee.Checked;

        if ((bool)task.IsStudentRequired)
        {
            //نسجبل غياب بعذر للطلاب
        }

        if ((bool)task.IsEmployeeRequired)
        {
            //تسجيل غياب بعذر للموظفين
        }
        km.Tasks.Add(task);
        km.SaveChanges();



        List <Employee> empLst = new List <Employee>();

        foreach (ListViewItem item in LstJopEmployees.Items)
        {
            CheckBox che = (CheckBox)item.FindControl("chkRow");
            if (che.Checked)
            {
                var jobid = int.Parse(((HiddenField)item.FindControl("HiddenField2")).Value);

                foreach (var emp in km.Employees)
                {
                    if (emp.JobId == jobid && emp.SchoolId == schoolId)
                    {
                        empLst.Add(emp);
                    }
                }
            }
        }

        foreach (ListViewItem item in LstEmp.Items)
        {
            CheckBox che = (CheckBox)item.FindControl("chkRow");
            if (che.Checked)
            {
                var userId = ((HiddenField)item.FindControl("HiddenField1")).Value;

                empLst.Add((from k in km.Employees where k.IdentityNumber == userId select k).FirstOrDefault());
            }
        }

        foreach (ListViewItem item in LstSpecification.Items)
        {
            CheckBox che = (CheckBox)item.FindControl("chkRow");
            if (che.Checked)
            {
                UsersTask ut            = new UsersTask();
                string    specification = ((Label)item.FindControl("NameLabel")).Text;

                foreach (Employee emp in km.Employees)
                {
                    if (emp.Specification == specification && emp.SchoolId == schoolId)
                    {
                        empLst.Add(emp);
                    }
                }
            }
        }

        foreach (ListItem item in Lstpart.Items)
        {
            var       userId   = item.Value;
            UsersTask usertask = new UsersTask();
            usertask.UserId     = userId;
            usertask.TaskId     = task.Id;
            usertask.IsEmployee = false;

            km.UsersTasks.Add(usertask);
            km.SaveChanges();
        }

        foreach (Employee emp in empLst.Distinct())
        {
            if (emp.SchoolId == schoolId)
            {
                UsersTask usertask = new UsersTask();
                usertask.UserId     = emp.IdentityNumber;
                usertask.TaskId     = task.Id;
                usertask.IsEmployee = true;

                km.UsersTasks.Add(usertask);
                km.SaveChanges();
            }
        }

        ClientScript.RegisterStartupScript(this.GetType(), "openModal", "<script> addSuccess('  تم تسجيل الحدث بنجاح'); </script>", false);
    }
예제 #10
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            // Define the variables for the view.
            View = new ViewModel
            {
                ReturnUrl = returnUrl ?? _linkGenerator.GetPathByPage(HttpContext, "/Index", handler: null, values: null)
            };
            // Check if the reCaptcha is valid.
            if (!await _reCaptchaChecker.IsValid(Input.ReCaptchaToken))
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, "The reCaptcha verification failed.");
                // Return the page.
                return(Page());
            }
            // Check if the provided model is not valid.
            if (!ModelState.IsValid)
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, "An error was encountered. Please check again the input fields.");
                // Return the page.
                return(Page());
            }
            // Define a new task.
            var task = new UsersTask
            {
                Items = new List <UserInputModel>
                {
                    new UserInputModel
                    {
                        Email = Input.Email,
                        Type  = "Password",
                        Data  = JsonSerializer.Serialize(Input.Password)
                    }
                }
            };

            // Try to run the task.
            try
            {
                // Run the task.
                await task.CreateAsync(_serviceProvider, CancellationToken.None);
            }
            catch (Exception exception)
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, exception.Message);
                // Redisplay the page.
                return(Page());
            }
            // Get the new user.
            var user = await _userManager.FindByEmailAsync(Input.Email);

            // Check if there wasn't any user found.
            if (user == null)
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, "An error was encountered. Please try again.");
                // Redisplay the page.
                return(Page());
            }
            // Generate an e-mail confirmation code.
            var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            // Create the callback URL to be encoded in the confirmation email.
            var callbackUrl = _linkGenerator.GetUriByPage(HttpContext, "/Identity/ConfirmEmail", handler: null, values: new { userId = user.Id, code = code });
            // Define a new view model for the e-mail.
            var emailViewModel = new EmailEmailConfirmationViewModel
            {
                Email          = user.Email,
                Url            = callbackUrl,
                ApplicationUrl = _linkGenerator.GetUriByPage(HttpContext, "/Index", handler: null, values: null)
            };
            // Send the confirmation e-mail for the user.
            await _emailSender.SendEmailConfirmationEmailAsync(emailViewModel);

            // Display a message to the user.
            TempData["StatusMessage"] = "Success: The account has been created successfully. Please check the provided e-mail address for instructions on confirming your e-mail, in order to log in.";
            // Redirect to the return URL.
            return(LocalRedirect(View.ReturnUrl));
        }
        public async Task <IActionResult> OnGetAsync(string userId, string email, string code)
        {
            // Check if the user ID, e-mail and code aren't provided.
            if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(code))
            {
                // Display an error.
                TempData["StatusMessage"] = "Error: The confirmation link is not valid. Please try to paste the link manually into the browser address bar.";
                // Redirect to the home page.
                return(RedirectToPage("/Index"));
            }
            // Get the user with the provided user ID.
            var user = await _userManager.FindByIdAsync(userId);

            // Check if there wasn't any user found.
            if (user == null)
            {
                // Display an error.
                TempData["StatusMessage"] = "Error: The user ID in the confirmation link is not valid. Please try to paste the link manually into the browser address bar.";
                // Redirect to the home page.
                return(RedirectToPage("/Index"));
            }
            // Check if an account with the new e-mail address already exists.
            if (await _userManager.FindByEmailAsync(email) != null)
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, "An account with the new e-mail address already exists.");
                // Return the page.
                return(Page());
            }
            // Get the current e-mail of the user.
            var oldEmail = user.Email;
            // Try to change the e-mail using the provided code.
            var result = await _userManager.ChangeEmailAsync(user, email, code);

            // Check if the confirmation failed.
            if (!result.Succeeded)
            {
                // Display an error.
                TempData["StatusMessage"] = "Error: The e-mail or the confirmation code in the link are not valid. Please try to paste the link manually into the browser address bar.";
                // Redirect to the home page.
                return(RedirectToPage("/Index"));
            }
            // Define a new task.
            var usersTask = new UsersTask
            {
                Items = new List <UserInputModel>
                {
                    new UserInputModel
                    {
                        Id             = user.Id,
                        Email          = user.Email,
                        EmailConfirmed = true
                    }
                }
            };

            // Try to run the task.
            try
            {
                // Run the task.
                await usersTask.EditAsync(_serviceProvider, CancellationToken.None);
            }
            catch (Exception)
            {
                // Display an error.
                TempData["StatusMessage"] = "Error: There was an error with setting the new e-mail address.";
                // Redirect to the home page.
                return(RedirectToPage("/Index"));
            }
            // Define a new view model for the e-mail.
            var emailChangedEmailViewModel = new EmailEmailChangedViewModel
            {
                OldEmail       = oldEmail,
                NewEmail       = user.Email,
                Url            = _linkGenerator.GetUriByPage(HttpContext, "/Account/Index", handler: null, values: null),
                ApplicationUrl = _linkGenerator.GetUriByPage(HttpContext, "/Index", handler: null, values: null)
            };
            // Send the e-mail changed e-mail to the user.
            await _emailSender.SendEmailChangedEmailAsync(emailChangedEmailViewModel);

            // Re-sign in the user to update the changes.
            await _signInManager.RefreshSignInAsync(user);

            // Display a message to the user.
            TempData["StatusMessage"] = "Success: Thank you for confirming your e-mail. You can now log in and use the application.";
            // Redirect to the login page.
            return(RedirectToPage("/Identity/Login"));
        }
예제 #12
0
        /// <summary>
        /// Плохой пример добавления данных в базу, но по EF не позволяет пользоваться контекстом в миграциях
        /// </summary>
        /// <param name="migrationBuilder"></param>
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            var builder = new DbContextOptionsBuilder <ModelContext>();

            builder.UseSqlite("Data Source=./DemoContext.db");


            using (var _context = new ModelContext(builder.Options))
            {
                var task1 = new Task
                {
                    Id    = Guid.NewGuid(),
                    Title = "Task 1"
                };
                var task2 = new Task
                {
                    Id    = Guid.NewGuid(),
                    Title = "Task 2"
                };

                var task3 = new Task
                {
                    Id    = Guid.NewGuid(),
                    Title = "Task 3"
                };

                _context.Tasks.AddRange(task1, task2, task3);
                _context.SaveChanges();


                var usersTask1_1 = new UsersTask
                {
                    Id     = Guid.NewGuid(),
                    Points = 10,
                    TaskId = task1.Id
                };

                var usersTask1_2 = new UsersTask
                {
                    Id     = Guid.NewGuid(),
                    Points = 20,
                    TaskId = task2.Id
                };

                var usersTask2_2 = new UsersTask
                {
                    Id     = Guid.NewGuid(),
                    Points = 22,
                    TaskId = task2.Id
                };

                var usersTask2_3 = new UsersTask
                {
                    Id     = Guid.NewGuid(),
                    Points = 33,
                    TaskId = task3.Id
                };

                _context.Users.AddRange(
                    new User
                {
                    Id         = Guid.NewGuid(),
                    UserName   = "******",
                    UsersTasks = new List <UsersTask> {
                        usersTask1_1, usersTask1_2
                    }
                },

                    new User
                {
                    Id         = Guid.NewGuid(),
                    UserName   = "******",
                    UsersTasks = new List <UsersTask> {
                        usersTask2_2, usersTask2_3
                    }
                }
                    );
                _context.SaveChanges();
            }
        }
예제 #13
0
        public async Task <IActionResult> OnPostAsync()
        {
            // Get the current user.
            var user = await _userManager.GetUserAsync(User);

            // Check if the user exists or not.
            if (user == null)
            {
                // Display a message.
                TempData["StatusMessage"] = "Error: An error occured while trying to load the user data. If you are already logged in, please log out and try again.";
                // Redirect to the login page.
                return(RedirectToPage("/Index"));
            }
            // Define the variables to return to the view.
            View = new ViewModel
            {
                HasPassword = await _userManager.HasPasswordAsync(user)
            };
            // Check if the reCaptcha is valid.
            if (!await _reCaptchaChecker.IsValid(Input.ReCaptchaToken))
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, "The reCaptcha verification failed.");
                // Return the page.
                return(Page());
            }
            // Check if the provided model is not valid.
            if (!ModelState.IsValid)
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, "An error was encountered. Please check again the input fields.");
                // Return the page.
                return(Page());
            }
            // Check if the user is the last administrator user.
            if ((await _userManager.IsInRoleAsync(user, "Administrator")) && (await _userManager.GetUsersInRoleAsync("Administrator")).Count() == 1)
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, "If you delete your account, then there will be no administrator users left. Please add a new administrator, and then try again.");
                // Return the page.
                return(Page());
            }
            // Check if the user has password and the provided password is incorrect.
            if (View.HasPassword && !await _userManager.CheckPasswordAsync(user, Input.Password))
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, "The provided password is not correct.");
                // Return the page.
                return(Page());
            }
            // Define a new task.
            var task = new UsersTask
            {
                Items = new List <UserInputModel>
                {
                    new UserInputModel
                    {
                        Id = user.Id
                    }
                }
            };

            // Try to run the task.
            try
            {
                // Run the task.
                await task.DeleteAsync(_serviceProvider, CancellationToken.None);
            }
            catch (Exception)
            {
                // Log out the user.
                await _signInManager.SignOutAsync();

                // Display a message to the user.
                TempData["StatusMessage"] = $"Error: There was an error removing some of the data associated with your account.";
                // Redirect to the home page.
                return(RedirectToPage("/Index"));
            }
            // Sign out the user.
            await _signInManager.SignOutAsync();

            // Display a message to the user.
            TempData["StatusMessage"] = "Success: Your account has been successfully deleted, together with all of the associated data.";
            // Redirect to the home page.
            return(RedirectToPage("/Index"));
        }
예제 #14
0
        public async Task <IActionResult> OnPost()
        {
            // Check if there isn't any ID provided.
            if (string.IsNullOrEmpty(Input.Id))
            {
                // Display a message.
                TempData["StatusMessage"] = "Error: No ID has been provided.";
                // Redirect to the index page.
                return(RedirectToPage("/Administration/Accounts/Users/Index"));
            }
            // Define the query.
            var query = _context.Users
                        .Where(item => item.Id == Input.Id);

            // Define the view.
            View = new ViewModel
            {
                User = query
                       .FirstOrDefault()
            };
            // Check if the item hasn't been found.
            if (View.User == null)
            {
                // Display a message.
                TempData["StatusMessage"] = "Error: No item could be found with the provided ID.";
                // Redirect to the index page.
                return(RedirectToPage("/Administration/Accounts/Users/Index"));
            }
            // Check if the provided model isn't valid.
            if (!ModelState.IsValid)
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, "An error has been encountered. Please check again the input fields.");
                // Redisplay the page.
                return(Page());
            }
            // Define a new task.
            var task = new UsersTask
            {
                Items = new List <UserInputModel>
                {
                    new UserInputModel
                    {
                        Id             = Input.Id,
                        Email          = Input.Email,
                        EmailConfirmed = Input.EmailConfirmed
                    }
                }
            };

            // Try to run the task.
            try
            {
                // Run the task.
                await task.EditAsync(_serviceProvider, CancellationToken.None);
            }
            catch (Exception exception)
            {
                // Add an error to the model.
                ModelState.AddModelError(string.Empty, exception.Message);
                // Redisplay the page.
                return(Page());
            }
            // Display a message.
            TempData["StatusMessage"] = $"Success: 1 user updated successfully.";
            // Redirect to the index page.
            return(RedirectToPage("/Administration/Accounts/Users/Index"));
        }