コード例 #1
0
        // update task
        public string Update(Task task)
        {
            Project project = unitOfWork.Project.Find(x => x.Id == task.ProjectId && x.State == 1);

            DateTime projectEndDate = DateTime.ParseExact(project.EndDate, "MM/dd/yyyy", null);
            DateTime taskEndDate    = DateTime.ParseExact(task.DueDate, "MM/dd/yyyy", null);

            DateTime startDate = DateTime.ParseExact(project.StartDate, "MM/dd/yyyy", null);

            if (projectEndDate > taskEndDate && startDate < taskEndDate)
            {
                unitOfWork.Tasks.Update(task);
                int rowsAffected = unitOfWork.Complete();

                if (rowsAffected > 0)
                {
                    return("1");
                }
                else
                {
                    return(Alert.AlertGenerate("Falied", "Falied", "Failed to Edit Task"));
                }
            }
            else
            {
                return(Alert.AlertGenerate("Falied", "Failed", "Invalid Date"));
            }
        }
コード例 #2
0
        public IActionResult Login(AuthenticationViewModel model)
        {
            if (ModelState.IsValid)
            {
                User user = authManager.CheckAuthentication(model);

                if (user != null)
                {
                    var userInfo = JsonConvert.SerializeObject(user);
                    HttpContext.Session.SetString("userInfo", userInfo);

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    HttpContext.Session.SetString("userInfo", "");

                    ViewData["Message"] = Alert.AlertGenerate("Falied", "Log in Falied", "Enter Valid Email or Password");
                    return(View());
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");
                ViewData["Message"] = Alert.AlertGenerate("Falied", "Log in Falied", "Fill up all fields correctly");
                return(View());
            }
        }
コード例 #3
0
        public IActionResult ChangePassword(ChangePasswordViewModel changePassword)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User userInfo = JsonConvert.DeserializeObject <User>(authData);

                if (ModelState.IsValid)
                {
                    string oldPassword = userInfo.Password;

                    if (oldPassword.Equals(changePassword.MainPassword))
                    {
                        if (changePassword.NewPassword.Equals(changePassword.ReNewPassword))
                        {
                            userInfo.Password = changePassword.NewPassword;

                            string updated = userManager.Update(userInfo);

                            if (updated.Equals("1"))
                            {
                                HttpContext.Session.SetString("userInfo", "");

                                return(RedirectToAction("Login", "LogIn"));
                            }
                            else
                            {
                                ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "Failed to Change Password");;
                                return(View());
                            }
                        }
                        else
                        {
                            ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "New and Re Entered Password does not matched");;
                            return(View(changePassword));
                        }
                    }
                    else
                    {
                        ViewData["Message"] = Alert.AlertGenerate("Warning", "Failed", "Enter Your Old Password Correctly");;
                        return(View());
                    }
                }
                else
                {
                    ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "Fill up all fields correctly");;
                    return(View());
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #4
0
        public IActionResult Edit(Comment comment)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User user = JsonConvert.DeserializeObject <User>(authData);

                if (commentManager.IsCommentExists(comment.Id))
                {
                    int userId = Convert.ToInt32(HttpContext.Session.GetInt32("UserId"));

                    if (comment.UserId == userId)
                    {
                        if (ModelState.IsValid)
                        {
                            comment.Date  = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt");
                            comment.State = 1;
                            comment.Seen  = 0;

                            string updated = commentManager.Update(comment);

                            if (updated.Equals("1"))
                            {
                                return(RedirectToAction("ViewComments", "Comment",
                                                        new { projectId = comment.ProjectId, taskId = comment.TaskId }));
                            }
                            else
                            {
                                ViewData["Message"] = updated;
                                return(View(comment));
                            }
                        }
                        else
                        {
                            ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "Fill up all fields correctly");;
                            return(View(comment));
                        }
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                else
                {
                    return(NotFound("404 Not Found"));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #5
0
        public IActionResult Edit(User user)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User userInfo = JsonConvert.DeserializeObject <User>(authData);

                if (userAccess.HasAccess(userInfo.Id, -20, userInfo.DesignationId))
                {
                    if (userManager.IsUserExists(user.Id))
                    {
                        if (ModelState.IsValid)
                        {
                            user.State = 1;
                            string updated = userManager.Update(user);

                            if (updated.Equals("1"))
                            {
                                return(RedirectToAction("ViewAll", "User"));
                            }
                            else
                            {
                                ViewBag.Designations = designationManager.GetDesignationsForDropDown();
                                ViewData["Message"]  = updated;
                                return(View(user));
                            }
                        }
                        else
                        {
                            ViewBag.Designations = designationManager.GetDesignationsForDropDown();
                            ViewData["Message"]  = Alert.AlertGenerate("Warning", "Failed", "Fill up all fields correctly");;
                            return(View(user));
                        }
                    }
                    else
                    {
                        return(NotFound("404 Not Found"));
                    }
                }
                else
                {
                    return(RedirectToAction("AccessDenied", "Home"));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #6
0
        public IActionResult Add(Comment comment)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User user = JsonConvert.DeserializeObject <User>(authData);

                int userId = Convert.ToInt32(HttpContext.Session.GetInt32("UserId"));

                if (ModelState.IsValid)
                {
                    comment.UserId = userId;
                    comment.State  = 1;
                    comment.Seen   = 0;
                    comment.Date   = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt");

                    string saved = commentManager.Save(comment);

                    if (saved.Equals("1"))
                    {
                        return(RedirectToAction("Details", "Project", new { id = comment.ProjectId }));
                    }
                    else
                    {
                        ViewBag.Tasks = taskManager.GetTasksByProjectIdForDropDown(comment.ProjectId);
                        ViewBag.Users = userManager.GetAssignedUserDropDownForComment(comment.ProjectId);

                        ViewData["ProjectId"] = comment.ProjectId;
                        ViewData["Message"]   = saved;

                        return(View(comment));
                    }
                }
                else
                {
                    ViewBag.Tasks = taskManager.GetTasksByProjectIdForDropDown(comment.ProjectId);
                    ViewBag.Users = userManager.GetAssignedUserDropDownForComment(comment.ProjectId);

                    ViewData["ProjectId"] = comment.ProjectId;
                    ViewData["Message"]   = Alert.AlertGenerate("Failed", "Failed", "Fill up all fields correctly");

                    return(View(comment));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #7
0
        // comment update
        public string Update(Comment comment)
        {
            unitOfWork.Comment.Update(comment);
            int rowsAffected = unitOfWork.Complete();

            if (rowsAffected > 0)
            {
                return("1");
            }
            else
            {
                return(Alert.AlertGenerate("Failed", "Failed", "Failed to Edit Comment"));
            }
        }
コード例 #8
0
        public IActionResult ProfilePicture(IFormFile profilePicture)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User userInfo = JsonConvert.DeserializeObject <User>(authData);

                if (profilePicture != null)
                {
                    string fileName = Guid.NewGuid().ToString() + "_" + userInfo.Name + "_" + profilePicture.FileName;

                    uploadFile.UploadProfilePicture(profilePicture, fileName);

                    userInfo.ProfileUrl = "http://www.project-manager.somee.com/ProfilePictures/" +
                                          fileName;

                    string update = userManager.Update(userInfo);

                    if (update.Equals("1"))
                    {
                        ViewData["Message"] = Alert.AlertGenerate("Success", "Success", "Profile Picture Uploaded Successfully");
                        ViewBag.PictureLink = userInfo.ProfileUrl;
                    }
                    else
                    {
                        ViewData["Message"] = update;
                        ViewBag.PictureLink = userInfo.ProfileUrl;
                    }

                    return(View());
                }
                else
                {
                    ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "Please Browse Picture to Upload");
                    ViewBag.PictureLink = userInfo.ProfileUrl;

                    return(View());
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #9
0
        public IActionResult AssignProject(AssignProject assignProject)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User user = JsonConvert.DeserializeObject <User>(authData);

                if (userAccess.HasAccess(user.Id, 3, user.DesignationId))
                {
                    if (ModelState.IsValid)
                    {
                        assignProject.State = 1;
                        ViewData["Message"] = assignProjectManager.Save(assignProject);

                        ViewBag.Users         = userManager.GetUsersForDropDownForAssignProject();
                        ViewBag.Projects      = projectManager.GetProjectsForDropDown();
                        ViewBag.AssignedUsers = assignProjectManager.GetAssignedUsers();
                        return(View());
                    }
                    else
                    {
                        ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "Fill up all fields correctly");

                        ViewBag.Users         = userManager.GetUsersForDropDownForAssignProject();
                        ViewBag.Projects      = projectManager.GetProjectsForDropDown();
                        ViewBag.AssignedUsers = assignProjectManager.GetAssignedUsers();
                        return(View());
                    }
                }
                else
                {
                    return(RedirectToAction("AccessDenied", "Home"));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #10
0
        // save
        public string Save(User user)
        {
            if (unitOfWork.User.IsExists(x => x.Email == user.Email))
            {
                return(Alert.AlertGenerate("Failed", "Already Exists", "User Email already exists"));
            }
            else
            {
                unitOfWork.User.Add(user);
                int rowsAffected = unitOfWork.Complete();

                if (rowsAffected > 0)
                {
                    return(Alert.AlertGenerate("Success", "Success", "Saved New User Successfully"));
                }
                else
                {
                    return(Alert.AlertGenerate("Failed", "Falied", "Falied to Save New User"));
                }
            }
        }
コード例 #11
0
        // update
        public string Update(Project project)
        {
            if (unitOfWork.Project.IsExists(x => x.Id != project.Id && x.CodeName == project.CodeName && x.State == 1))
            {
                return(Alert.AlertGenerate("Failed", "Failed", "Same Project Code project Already Exists"));
            }
            else
            {
                unitOfWork.Project.Update(project);
                int rowsAffected = unitOfWork.Complete();

                if (rowsAffected > 0)
                {
                    return("1");
                }
                else
                {
                    return(Alert.AlertGenerate("Failed", "Failed", "Failed to Update Project"));
                }
            }
        }
コード例 #12
0
        //save
        public string Save(Project project)
        {
            if (unitOfWork.Project.IsExists(x => x.CodeName == project.CodeName && x.State == 1))
            {
                return(Alert.AlertGenerate("Failed", "Failed", "Same Project Code project Already Exists"));
            }
            else
            {
                unitOfWork.Project.Add(project);
                int rowsAffected = unitOfWork.Complete();

                if (rowsAffected > 0)
                {
                    return(Alert.AlertGenerate("Success", "Success", "New Project Saved and Uploaded Successfully"));
                }
                else
                {
                    return(Alert.AlertGenerate("Failed", "Failed", "Failed to Save New Project"));
                }
            }
        }
コード例 #13
0
        // save designation
        public string Save(Designation designation)
        {
            if (unitOfWork.Designation.IsExists(x => x.DesignationName == designation.DesignationName && x.State != 0))
            {
                return(Alert.AlertGenerate("Warning", "Already Exists", "Designation already exists"));
            }
            else
            {
                unitOfWork.Designation.Add(designation);
                int rowsAffected = unitOfWork.Complete();

                if (rowsAffected > 0)
                {
                    return(Alert.AlertGenerate("Success", "Success", "Designation Saved Successfully"));
                }
                else
                {
                    return(Alert.AlertGenerate("Failed", "Failed", "Failed to Save Designation"));
                }
            }
        }
コード例 #14
0
        //update
        public string Update(User user)
        {
            if (unitOfWork.User.IsExists(x => x.Id != user.Id && x.Email == user.Email && x.State == 1))
            {
                return(Alert.AlertGenerate("Failed", "Already Exists", "User Email already exists"));
            }
            else
            {
                unitOfWork.User.Update(user);
                int rowsAffected = unitOfWork.Complete();

                if (rowsAffected > 0)
                {
                    return("1");
                }
                else
                {
                    return(Alert.AlertGenerate("Failed", "Failed", "Failed to Edit User"));
                }
            }
        }
コード例 #15
0
        // assign project to user
        public string Save(AssignProject assignProject)
        {
            if (unitOfWork.AssignProject.IsExists(x =>
                                                  x.UserId == assignProject.UserId && x.ProjectId == assignProject.ProjectId && x.State == 1))
            {
                return(Alert.AlertGenerate("Falied", "Failed", "Already Project Assigned to Another User"));
            }
            else
            {
                unitOfWork.AssignProject.Add(assignProject);
                int rowsAffected = unitOfWork.Complete();

                if (rowsAffected > 0)
                {
                    return(Alert.AlertGenerate("Success", "Success", "Project Assigned Successfully"));
                }
                else
                {
                    return(Alert.AlertGenerate("Falied", "Failed", "Failed to Assigned Project"));
                }
            }
        }
コード例 #16
0
        // update
        public string Update(Designation designation)
        {
            if (unitOfWork.Designation.IsExists(x =>
                                                x.Id != designation.Id && x.DesignationName == designation.DesignationName && x.State == 1))
            {
                return(Alert.AlertGenerate("Warning", "Already Exists", "Designation already exists"));
            }
            else
            {
                unitOfWork.Designation.Update(designation);
                int rowsAffected = unitOfWork.Complete();

                if (rowsAffected > 0)
                {
                    return("1");
                }
                else
                {
                    return(Alert.AlertGenerate("Failed", "Failed", "Failed to Update Designation"));
                }
            }
        }
コード例 #17
0
        public IActionResult Save(User user)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User userInfo = JsonConvert.DeserializeObject <User>(authData);

                if (userAccess.HasAccess(userInfo.Id, -20, userInfo.DesignationId))
                {
                    if (ModelState.IsValid)
                    {
                        user.State          = 1;
                        user.ProfileUrl     = "http://www.project-manager.somee.com/ProfilePictures/avater.jpg";
                        ViewData["Message"] = userManager.Save(user);
                        ModelState.Clear();
                        ViewBag.Designations = designationManager.GetDesignationsForDropDown();
                        return(View());
                    }
                    else
                    {
                        ViewData["Message"]  = Alert.AlertGenerate("Warning", "Failed", "Fill up all fields correctly");;
                        ViewBag.Designations = designationManager.GetDesignationsForDropDown();
                        return(View(user));
                    }
                }
                else
                {
                    return(RedirectToAction("AccessDenied", "Home"));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #18
0
        public IActionResult Add(Task task)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User user = JsonConvert.DeserializeObject <User>(authData);

                if (userAccess.HasAccess(user.Id, 2, user.DesignationId))
                {
                    if (ModelState.IsValid)
                    {
                        task.ByUserId = user.Id;
                        task.State    = 1;
                        task.Seen     = 0;

                        ViewData["Message"] = taskManager.Save(task);
                    }
                    else
                    {
                        ViewData["Message"] = Alert.AlertGenerate("Falied", "Falied", "Fill up all fields correctly");;
                    }

                    ViewBag.Projects = projectManager.GetProjectsForDropDown();
                    return(View());
                }
                else
                {
                    return(RedirectToAction("AccessDenied", "Home"));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #19
0
        public IActionResult Save(Designation designation)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User user = JsonConvert.DeserializeObject <User>(authData);

                if (userAccess.HasAccess(user.Id, -30, user.DesignationId))
                {
                    if (ModelState.IsValid)
                    {
                        designation.State   = 1;
                        ViewData["Message"] = designationManager.Save(designation);

                        ModelState.Clear();
                        return(View());
                    }
                    else
                    {
                        ViewData["Message"] = Alert.AlertGenerate("Failed", "Falied", "Fill up all fields correctly");
                        return(View(designation));
                    }
                }
                else
                {
                    return(RedirectToAction("AccessDenied", "Home"));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #20
0
        public IActionResult Add(Project project, List <IFormFile> files)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User user = JsonConvert.DeserializeObject <User>(authData);

                if (userAccess.HasAccess(user.Id, 1, user.DesignationId))
                {
                    if (ModelState.IsValid)
                    {
                        if (files.Count <= 0)
                        {
                            project.State       = 1;
                            ViewData["Message"] = projectManager.Save(project);
                            ModelState.Clear();
                            return(View());
                        }
                        else
                        {
                            DateTime startDate = DateTime.ParseExact(project.StartDate, "MM/dd/yyyy", null);
                            DateTime endDate   = DateTime.ParseExact(project.EndDate, "MM/dd/yyyy", null);

                            if (endDate > startDate)
                            {
                                project.State = 1;
                                List <File> fileList = new List <File>();

                                foreach (IFormFile file in files)
                                {
                                    Models.File fileObj = new File();

                                    fileObj.FileName              = file.FileName;
                                    fileObj.FileExtension         = file.ContentType;
                                    fileObj.FileNameWithExtension = fileObj.FileName + "." + fileObj.FileExtension;
                                    fileObj.State = 1;

                                    string fileName = Guid.NewGuid().ToString() + "_" + fileObj.FileName;
                                    fileObj.Url = "http://www.project-manager.somee.com/ProjectFiles/" + fileName;

                                    fileUpload.UploadOnRemoteServer(file, fileName);
                                    fileList.Add(fileObj);
                                }

                                project.Files = fileList;

                                ViewData["Message"] = projectManager.Save(project);
                                ModelState.Clear();
                                return(View());
                            }
                            else
                            {
                                ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "Invalid Start and End Date");
                                return(View(project));
                            }
                        }
                    }
                    else
                    {
                        ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "Fill up all fields correctly");
                        return(View(project));
                    }
                }
                else
                {
                    return(RedirectToAction("AccessDenied", "Home"));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #21
0
        public IActionResult Edit(Project project, IFormFile file, string fileId)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User user = JsonConvert.DeserializeObject <User>(authData);

                if (userAccess.HasAccess(user.Id, 1, user.DesignationId))
                {
                    if (projectManager.IsProjectExists(project.Id))
                    {
                        if (ModelState.IsValid)
                        {
                            DateTime startDate = DateTime.ParseExact(project.StartDate, "MM/dd/yyyy", null);
                            DateTime endDate   = DateTime.ParseExact(project.EndDate, "MM/dd/yyyy", null);

                            if (endDate > startDate)
                            {
                                if (fileId != null)
                                {
                                    project.State = 1;
                                    Models.File fileModel = fileManager.GetFileById(Convert.ToInt32(fileId));

                                    fileModel.FileName              = file.FileName;
                                    fileModel.FileExtension         = file.ContentType;
                                    fileModel.FileNameWithExtension =
                                        fileModel.FileName + "." + fileModel.FileExtension;

                                    string fileName = Guid.NewGuid().ToString() + "_" + fileModel.FileName;
                                    fileModel.Url = "http://www.project-manager.somee.com/ProjectFiles/" + fileName;

                                    List <File> files = new List <File>();
                                    fileUpload.UploadOnRemoteServer(file, fileName);
                                    files.Add(fileModel);

                                    project.Files = files;

                                    string updated = projectManager.Update(project);

                                    if (updated.Equals("1"))
                                    {
                                        return(RedirectToAction("ViewAll", "Project"));
                                    }
                                    else
                                    {
                                        ViewData["Message"] = updated;
                                        ViewBag.Files       = fileManager.GetFileForDropDown(project.Id);
                                        return(View(project));
                                    }
                                }
                                else
                                {
                                    // adding new file on existing project
                                    if (file != null)
                                    {
                                        project.State = 1;

                                        Models.File fileModel = new File();

                                        fileModel.ProjectId             = project.Id;
                                        fileModel.FileName              = file.FileName;
                                        fileModel.FileExtension         = file.ContentType;
                                        fileModel.State                 = 1;
                                        fileModel.FileNameWithExtension =
                                            fileModel.FileName + "." + fileModel.FileExtension;

                                        string fileName = Guid.NewGuid().ToString() + "_" + fileModel.FileName;
                                        fileModel.Url = "http://www.project-manager.somee.com/ProjectFiles/" + fileName;

                                        List <File> files = new List <File>();
                                        fileUpload.UploadOnRemoteServer(file, fileName);
                                        files.Add(fileModel);

                                        project.Files = files;

                                        string updated = projectManager.Update(project);

                                        if (updated.Equals("1"))
                                        {
                                            return(RedirectToAction("ViewAll", "Project"));
                                        }
                                        else
                                        {
                                            ViewData["Message"] = updated;
                                            ViewBag.Files       = fileManager.GetFileForDropDown(project.Id);
                                            return(View(project));
                                        }
                                    }
                                    else
                                    {
                                        project.State = 1;
                                        string updated = projectManager.Update(project);

                                        if (updated.Equals("1"))
                                        {
                                            return(RedirectToAction("ViewAll", "Project"));
                                        }
                                        else
                                        {
                                            ViewData["Message"] = updated;
                                            ViewBag.Files       = fileManager.GetFileForDropDown(project.Id);
                                            return(View(project));
                                        }
                                    }
                                }
                            }
                            else
                            {
                                ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "Invalid Start and End Date");
                                ViewBag.Files       = fileManager.GetFileForDropDown(project.Id);
                                return(View(project));
                            }
                        }
                        else
                        {
                            ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "Fill up all fields correctly");
                            ViewBag.Files       = fileManager.GetFileForDropDown(project.Id);
                            return(View(project));
                        }
                    }
                    else
                    {
                        return(NotFound("404 Not Found"));
                    }
                }
                else
                {
                    return(RedirectToAction("AccessDenied", "Home"));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #22
0
        public IActionResult Edit(Task task, int projectId)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User user = JsonConvert.DeserializeObject <User>(authData);

                if (userAccess.HasAccess(user.Id, 2, user.DesignationId))
                {
                    int userId = Convert.ToInt32(HttpContext.Session.GetInt32("UserId"));

                    if (userId == task.ByUserId)
                    {
                        if (ModelState.IsValid)
                        {
                            task.State = 1;
                            task.Seen  = 0;
                            string updated = taskManager.Update(task);

                            if (updated.Equals("1"))
                            {
                                return(RedirectToAction("Details", "Project", new { id = projectId }));
                            }
                            else
                            {
                                ViewData["Message"] = updated;

                                ViewBag.Projects = projectManager.GetProjectsForDropDown();
                                ViewBag.Users    = userManager.GetAssignedUserDropDownForEdit(userId);

                                return(View(task));
                            }
                        }
                        else
                        {
                            ViewData["Message"] = Alert.AlertGenerate("Failed", "Failed", "Fill up all fields correctly");

                            ViewBag.Projects = projectManager.GetProjectsForDropDown();
                            ViewBag.Users    = userManager.GetAssignedUserDropDownForEdit(userId);

                            return(View(task));
                        }
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                else
                {
                    return(RedirectToAction("AccessDenied", "Home"));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }
コード例 #23
0
        public IActionResult UserAccess(UserAccessViewModel userAccessViewModel)
        {
            var authData = HttpContext.Session.GetString("userInfo");

            if (authData != "")
            {
                User userInfo = JsonConvert.DeserializeObject <User>(authData);

                if (userAccess.HasAccess(userInfo.Id, -10, userInfo.DesignationId))
                {
                    if (userManager.IsUserExists(userAccessViewModel.UserId))
                    {
                        if (ModelState.IsValid)
                        {
                            if (userAccessViewModel.PageId == null)
                            {
                                int saved = userAccess.RemoveAllAccess(userAccessViewModel.UserId);

                                if (saved == 1)
                                {
                                    return(RedirectToAction("ViewAll", "User"));
                                }
                                else
                                {
                                    ViewBag.UserId      = userAccessViewModel.UserId;
                                    ViewData["Message"] = saved;
                                    UserAccessViewModel userAccessViewModelReturn = userAccess.GetUserAccess(userAccessViewModel.UserId);
                                    return(View(userAccessViewModelReturn));
                                }
                            }
                            else
                            {
                                userAccessViewModel.State = 1;
                                int saved = userAccess.SaveOrUpdate(userAccessViewModel);

                                if (saved == 1)
                                {
                                    return(RedirectToAction("ViewAll", "User"));
                                }
                                else
                                {
                                    ViewBag.UserId      = userAccessViewModel.UserId;
                                    ViewData["Message"] = saved;
                                    UserAccessViewModel userAccessViewModelReturn = userAccess.GetUserAccess(userAccessViewModel.UserId);
                                    return(View(userAccessViewModelReturn));
                                }
                            }
                        }
                        else
                        {
                            ViewBag.UserId      = userAccessViewModel.UserId;
                            ViewData["Message"] = Alert.AlertGenerate("Failed", "Falied", "Fill up all fields correctly");
                            UserAccessViewModel userAccessViewModelReturn = userAccess.GetUserAccess(userAccessViewModel.UserId);
                            return(View(userAccessViewModelReturn));
                        }
                    }
                    else
                    {
                        return(NotFound("404 Not Found"));
                    }
                }
                else
                {
                    return(RedirectToAction("AccessDenied", "Home"));
                }
            }
            else
            {
                HttpContext.Session.SetString("userInfo", "");

                return(RedirectToAction("Login", "LogIn"));
            }
        }