public ActionResult newUser(User user)
        {
            if (ModelState.IsValid)
            {
                var  dep = _departmentService.GetDepartmentByID(user.DepartmentID);
                User newUser;

                if (Company.CurrentUser != null && (Company.CurrentUser.UserType).Equals(UserType.Administrator))
                {
                    newUser = _userService.InsertUserByAdmin(user.UserName, user.Password, user.FirstName, user.LastName, user.Gender, user.Birthday, user.UserType, user.DepartmentID);
                }
                else
                {
                    newUser = _userService.InsertUser(user.UserName, user.Password, user.FirstName, user.LastName, user.Gender, user.Birthday, user.DepartmentID);
                }

                if (newUser != null && Company.CurrentUser == null)
                {
                    return(View("Success"));
                }

                else if (newUser != null && (Company.CurrentUser.UserType).Equals(UserType.Administrator))
                {
                    return(View("SuccessAdmin"));
                }
            }
            else
            {
                ModelState.AddModelError("", "Invalid data");
            }
            return(View("newUser"));
        }
예제 #2
0
        //------------------UPDATE  DEPARTMENT------------------------------------------
        // GET: /Department/Edit/2
        public ActionResult Edit(int id)
        {
            if ((Company.CurrentUser.UserType).Equals(UserType.Administrator))
            {
                DepartmentModel depModel = new DepartmentModel();
                List <Company>  ComList  = new List <Company>();
                depModel.Companies = _companyService.GetAllCompanies();
                ViewBag.comList    = depModel.Companies;

                Department department = _departmentService.GetDepartmentByID(id);
                return(View(department));
            }
            else
            {
                return(RedirectToAction("NotAdministrator"));
            }
        }
예제 #3
0
        public ActionResult Edit(Project project)
        {
            if (project != null)
            {
                project.ManagerID    = Company.CurrentUser.Id;
                project.DepartmentID = Company.CurrentUser.DepartmentID;
                Department department = _departmentService.GetDepartmentByID(project.DepartmentID);
                User       manager    = _userService.GetUserByID(Company.CurrentUser.Id);

                if (department != null && manager != null)
                {
                    var updateProject = _projectService.UpdateProject(project);
                }
            }
            else
            {
                return(View("Fail", "Project"));
            }
            return(RedirectToAction("getProjects", "Project"));
        }