Example #1
0
        public ActionResult Add(ManageProfileSeatingPlanViewModel model)
        {
            var commandDto = model.manageProfileModel.ToDto();
            string imgUrl = Session["tempProfileImageUrl"] as string;
            string cartoonUrl = Session["tempProfileImageUrl2"] as string;
            string confirmationMessage = "Profile added successfully.";
            var user = System.Web.HttpContext.Current.User.Identity.Name.Remove(0, 11);

            if (model.manageProfileModel.ProfileId == 0)
            {
                employeeRepository.AddProfile(commandDto, imgUrl, cartoonUrl);
                Session.Remove("tempProfileImageUrl");
                Session.Remove("tempProfileImageUrl2");
                base.RefreshSignedInUser();
            }
            else
            {
                employeeRepository.UpdateProfile(commandDto, imgUrl, cartoonUrl);
                confirmationMessage = "Profile updated successfully.";
            }

            base.LogAction("Employee" + (model.manageProfileModel.ProfileId == 0 ? " Created" : " Modified") + " by " + user);
            TempData["Message"] = confirmationMessage;
            return RedirectToAction("Index", "Home");
        }
Example #2
0
        public ActionResult Add()
        {
            // do not display the add page, if you're already registered
            string name = User.Identity.Name;
            if (SignedInUser.WindowsIdentity == name)
                return RedirectToRoute(new {Controller = "Profile", Action = "edit"});

            ViewBag.DisplayOption = "Add";

            // Help with prefilling some fields....
            name = name.Replace("\\", ","); // hack to change backslash to comma so that it can be split easily.
            string fname = name.Split(',')[1].Split('.')[0];
            string lname = name.Split(',')[1].Split('.')[1];

            ManageProfileViewModel profileModel = new ManageProfileViewModel
                                                   {
                                                       FirstName = fname,
                                                       LastName = lname,
                                                       Emailaddress = name.Split(',')[1] + "@reedonline.co.uk"
                                                   };

            ProfileViewModel seatingplanModel = employeeRepository.GetEmployeesByFloor();
            ManageProfileSeatingPlanViewModel viewModel = new ManageProfileSeatingPlanViewModel
                                                              {
                                                                  employeesByFloorModel = seatingplanModel,
                                                                  manageProfileModel = profileModel
                                                              };

            return View(PopulateDropdowns(viewModel));
        }
Example #3
0
 private ManageProfileSeatingPlanViewModel PopulateDropdowns(ManageProfileSeatingPlanViewModel model)
 {
     model.manageProfileModel.Department = new SelectList(departmentRepository.GetTopLevelDepartments(), "Id", "Name", model.manageProfileModel.DepartmentId);
     model.manageProfileModel.Role = new SelectList(roleRepository.GetAllRoles(), "Id", "Name", model.manageProfileModel.RoleId);
     model.manageProfileModel.Floors = new SelectList(seatingFloorRespository.GetAllSeatingFloors(), "Id", "Name", model.manageProfileModel.SeatingFloor);
     return model;
 }
Example #4
0
        public ActionResult Edit()
        {
            var model = new ManageProfileViewModel();
            var windowsIdentity = System.Web.HttpContext.Current.User.Identity.Name;

            var profile = GetProfileByWindowsIdentity(windowsIdentity);
            if (profile == null)
            {
              TempData["Message"] = "User does not exist";
              RedirectToAction("index", "home");
            }
            else
            {
              model.ToModel(profile);
              ViewBag.DisplayOption = "Edit";
            }

            ProfileViewModel seatingplanModel = employeeRepository.GetEmployeesByFloor();
            ManageProfileSeatingPlanViewModel viewModel = new ManageProfileSeatingPlanViewModel
            {
                employeesByFloorModel = seatingplanModel,
                manageProfileModel = model
            };

            return View("Add", PopulateDropdowns(viewModel));
        }