コード例 #1
0
        public IActionResult Index(StaffProfile p)
        {
            if (p != null)
            {
                StaffProfile profile = profileRepo.GetStaffProfileByID(p.StaffProfileID);
                profile.FirstName          = p.FirstName;
                profile.LastName           = p.LastName;
                profile.EmailNotifications = p.EmailNotifications;

                int verify = profileRepo.UpdateStaff(profile);
                if (verify == 1)
                {
                    //TODO add feedback of success
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    //TODO add feedback for error
                }
            }
            else
            {
                ModelState.AddModelError("", "User Not Found");
            }
            return(View(p));
        }
コード例 #2
0
        public IActionResult AddKWTask(KWTaskVM vm, int?staffProfileID, string returnURL)
        {
            var kwtask = new KWTask
            {
                Message     = vm.NewKWTask.Message,
                AlertDate   = vm.NewKWTask.AlertDate,
                DateCreated = vm.NewKWTask.DateCreated,
                DateDue     = vm.NewKWTask.DateDue,
                Priority    = vm.NewKWTask.Priority
            };

            if (kwtask.AlertDate == null)
            {
                kwtask.Type = "Task";
            }
            else
            {
                kwtask.Type = "Alert";
            }

            if (staffProfileID != null)
            {
                StaffProfile staff = staffRepo.GetStaffProfileByID((int)staffProfileID);
                staff.Tasks.Add(kwtask);
            }

            taskRepo.AddKWTask(kwtask);

            //TODO: See if there is a way to just close the modal and not refresh the page
            return(Redirect(returnURL));
        }
コード例 #3
0
        public async Task <IActionResult> StaffDelete(int id)
        {
            StaffProfile profile = staffRepo.GetStaffProfileByID(id);

            if (profile != null)
            {
                StaffUser user = await userManager.FindByNameAsync(profile.Email);

                await userManager.DeleteAsync(user);

                staffRepo.DeleteStaff(profile);
                return(RedirectToAction("Staff"));
            }
            else
            {
                ModelState.AddModelError("", "Staff Not Found");
            }
            return(RedirectToAction("Home"));
        }