/// <summary>
        /// function that gets all users of a project and puts them in dropdown list
        /// </summary>
        /// <param name="id">the project id</param>
        /// <returns>return select list of users</returns>
        public IEnumerable <SelectListItem> GetUsers(int?id)
        {
            using (var context = new ReviseDBEntities())
            {
                List <user>     Allusers = context.users.ToList();
                List <projUser> prj      = context.projUsers.Where(p => p.projid == id).ToList();
                List <user>     usr      = new List <user>();
                foreach (var p in prj)
                {
                    usr.Add(p.user);
                }

                foreach (var u in usr)
                {
                    Allusers.Remove(u);
                }

                List <SelectListItem> users = Allusers
                                              .OrderBy(n => n.UserName)
                                              .Select(n =>
                                                      new SelectListItem
                {
                    Value = n.UserName.ToString(),
                    Text  = n.fname + " " + n.lname
                }).ToList();
                var userType = new SelectListItem()
                {
                    Value = null,
                    Text  = "Assign users:"
                };
                users.Insert(0, userType);
                return(new SelectList(users, "Value", "Text"));
            }
        }
Пример #2
0
        public ActionResult Requirement()
        {
            //getting the project and category id
            int projId = Convert.ToInt32(Session["projectid"]);
            int catId  = Convert.ToInt32(Session["Catid"]);

            //checks if a requirement exist
            ReviseDBEntities con = new ReviseDBEntities();
            int req = 0;

            if (con.requirements.Where(p => p.projid == projId).SingleOrDefault(c => c.catid == catId) != null)
            {
                req = con.requirements.Where(p => p.projid == projId).SingleOrDefault(c => c.catid == catId).reqId;
            }
            if (req == 0)
            {
                Session["ReqExisit"] = 0;
                return(View());
            }
            else
            {
                Session["ReqId"]     = req;
                Session["ReqExisit"] = 1;
                var repo = new MainRepository();
                var Main = repo.Requirement(req);
                return(View(Main));
            }
        }
        /// <summary>
        /// function that create view for category main
        /// </summary>
        /// <param name="uid">user id</param>
        /// <param name="pid">project id</param>
        /// <returns>returns updated model to show in the view</returns>
        public CategoryMain CatView(string uid, int?pid)
        {
            List <category>  CatList = new List <category>();
            ReviseDBEntities con     = new ReviseDBEntities();
            var prjcat = con.projCats.Where(p => p.projId == pid).ToList();

            foreach (var cat in con.categories)
            {
                foreach (var prj in prjcat)
                {
                    if (prj.catId == cat.CatId)
                    {
                        CatList.Add(cat);
                    }
                }
            }
            int roleNum = 7;

            if (con.projUsers.Where(u => u.userid == uid).SingleOrDefault(p => p.projid == pid) != null)
            {
                roleNum = con.projUsers.Where(u => u.userid == uid).SingleOrDefault(p => p.projid == pid).role ?? 7;
            }

            var ShowView = new CategoryMain()
            {
                Cat  = CatList,
                role = roleNum
            };

            return(ShowView);
        }
Пример #4
0
        public ActionResult RenewPass(string EmailID)
        {
            string message = "";

            using (var con = new ReviseDBEntities())
            {
                var account = con.users.Where(a => a.Email == EmailID).FirstOrDefault();
                if (account != null)
                {
                    //Send email for reset password
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLinkEmail(account.Email, resetCode, "ResetPassword");
                    account.ResetPasswordCode = resetCode;
                    //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property
                    //in our model class in part 1
                    con.Configuration.ValidateOnSaveEnabled = false;
                    con.SaveChanges();
                    message = "Reset password link has been sent to your email id.";
                }
                else
                {
                    message = "Account not found";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
Пример #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            int projid           = Convert.ToInt32(Session["projectid"]);
            ReviseDBEntities con = new ReviseDBEntities();

            //finds the category in DB, delete it from the specific project
            category cat    = con.categories.Find(id);
            var      catprj = con.projCats.Where(c => c.catId == id).SingleOrDefault(p => p.projId == projid);

            con.projCats.Remove(catprj);

            var catreq = con.requirements.Where(c => c.catid == id).SingleOrDefault(p => p.projid == projid);

            if (catreq != null)
            {
                con.requirements.Remove(catreq);
            }

            var message = con.messages.Where(c => c.CatId == id).Where(p => p.projId == projid).ToList();

            if (message != null)
            {
                foreach (var msg in message)
                {
                    con.messages.Remove(msg);
                }
            }

            con.SaveChanges();
            return(RedirectToAction("CategoryMain", "Category", new { id = projid, name = Session["projectName"].ToString() }));
        }
Пример #6
0
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (var con = new ReviseDBEntities())
                {
                    var user = con.users.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault();
                    if (user != null)
                    {
                        // user.password = Crypto.Hash(model.NewPassword);
                        user.password          = model.NewPassword;
                        user.ResetPasswordCode = "";
                        con.Configuration.ValidateOnSaveEnabled = false;
                        con.SaveChanges();
                        message = "New password updated successfully";
                    }
                }
            }
            else
            {
                message = "Something invalid";
            }
            ViewBag.Message = message;
            return(View(model));
        }
Пример #7
0
        public ActionResult Gamification(IEnumerable <string> SelectedGame)
        {
            //if no method selected
            if (SelectedGame == null)
            {
                TempData["NoGame"] = "No gamfication method selected";
                return(RedirectToAction("ProjectMain", "Project"));
            }

            var ChooseAssignGame = SelectedGame.ToList();
            int proj             = Convert.ToInt32(Session["GameProjId"]); //gets project id
            ReviseDBEntities con = new ReviseDBEntities();

            if (ChooseAssignGame.SingleOrDefault() == "")
            {
                TempData["NoGame"] = "No gamfication method selected";
                return(RedirectToAction("ProjectMain", "Project"));
            }
            else  //update the projet gamification method
            {
                int game_id = Int32.Parse(ChooseAssignGame.SingleOrDefault());
                var game    = con.gamifications.Where(g => g.gamId == game_id);
                con.projects.Find(proj).game         = game_id;
                con.projects.Find(proj).gamification = con.gamifications.Find(game_id);
            }

            con.SaveChanges();
            return(RedirectToAction("ProjectMain", "Project"));
        }
Пример #8
0
        public ActionResult PersonalFile(string firstname, string lastname, string UserId, string username, string phonenum, string EmailID, string pic)
        {
            ReviseDBEntities con      = new ReviseDBEntities(); //connection to the DB
            string           userInfo = Session["userid"].ToString();
            var isUserExists          = false;

            if (firstname == con.users.Find(userInfo).fname&& lastname == con.users.Find(userInfo).lname&& username == con.users.Find(userInfo).UserName&&
                EmailID == con.users.Find(userInfo).Email&& phonenum == con.users.Find(userInfo).PhoneNum&& string.IsNullOrEmpty(pic))    //checks if the information equal to the one in the DB
            {
                TempData["NoInfoChanges"] = "No Changes where made";
                return(RedirectToAction("PersonalFile", "Authentication"));
            }

            if (string.IsNullOrEmpty(pic) && string.IsNullOrEmpty(con.users.Find(userInfo).pic))    //if no picture provided now and thers no picture in the DB, assign the default
            {
                pic = "https://he.gravatar.com/userimage/138919762/622efbcbeb0e8cea9b64cf6e8bffffc0.jpg";
            }

            #region Save to Database
            try
            {
                using (var conn = new ReviseDBEntities())
                {
                    foreach (var usr in conn.users)
                    {
                        if (usr.userid != userInfo)
                        {
                            if (usr.UserName == username || usr.Email == EmailID)
                            {
                                isUserExists = true;
                            }
                        }
                    }

                    if (!isUserExists)   //updating the user information
                    {
                        conn.users.Find(userInfo).Email    = EmailID;
                        conn.users.Find(userInfo).fname    = firstname;
                        conn.users.Find(userInfo).lname    = lastname;
                        conn.users.Find(userInfo).UserName = username;
                        conn.users.Find(userInfo).PhoneNum = phonenum;
                        if (!string.IsNullOrEmpty(pic))
                        {
                            conn.users.Find(userInfo).pic = pic;
                        }
                        conn.SaveChanges();
                        #endregion
                        return(RedirectToAction("ProjectMain", "Project"));
                    }
                    TempData["UserExist"] = "User with this user name or email is already exists";
                    return(RedirectToAction("PersonalFile", "Authentication"));
                }
            }
            catch
            {
                TempData["Unknown"] = "Unknown error occurred!";
                return(RedirectToAction("PersonalFile", "Authentication"));
            }
        }
Пример #9
0
        public ActionResult Login(string username, string password)
        {
            try
            {
                if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) //if the user didn't fill in the details
                {
                    TempData["EmptyLogin"] = "******";
                    return(RedirectToAction("Login", "Authentication"));
                }
                using (var con = new ReviseDBEntities())
                {
                    var usr   = username;
                    var users = con.users.Where(u => u.UserName == usr).ToList();
                    var user  = users.First();
                    if (users.First().isConnected == 1) //checks if the user is already connected
                    {
                        TempData["UserLogin"] = "******";
                        return(RedirectToAction("Login", "Authentication"));
                    }

                    if (users.First().password == password) //checks the password matches the regestration password
                    {
                        users.First().isConnected = 1;      //marking the user as "connected"
                        con.SaveChanges();
                        System.Web.HttpContext.Current.Session["username"] = user.UserName;
                        Session["userid"]  = user.userid;
                        Session["IsAdmin"] = user.IsAdmin;
                        if (user.score != null)
                        {
                            Session["UserScore"] = user.score;
                        }
                        else
                        {
                            Session["UserScore"] = 0;
                        }
                        System.Web.HttpContext.Current.Session.Timeout = 30;
                        return(RedirectToAction("ProjectMain", "Project"));
                    }
                    else
                    {
                        TempData["FailedLogin"] = "******";
                        return(RedirectToAction("Login", "Authentication"));
                    }
                }
            }
            catch (FormatException)
            {
                TempData["UserName"] = "******";
                return(RedirectToAction("Login", "Authentication"));
            }
            catch
            {
                TempData["Unknown"] = "Unknown error occurred!";
                return(RedirectToAction("Login", "Authentication"));
            }
        }
Пример #10
0
        public ActionResult ProjectDetails(int?id)
        {
            Session["projId"] = id;   //updating project id
            var repo              = new MainRepository();
            var Main              = repo.ProjView(id);
            ReviseDBEntities con  = new ReviseDBEntities();
            List <projUser>  proj = con.projUsers.Where(p => p.projid == id).ToList(); //get all the participents of the project

            ViewBag.members = proj;
            return(View(Main));
        }
        /// <summary>
        /// function that create view for vote page
        /// </summary>
        /// <param name="reqid">requirement id</param>
        /// <param name="usrid">user id</param>
        /// <returns>returns updated model to show in the view</returns>
        public ReqRate Vote(int reqid, string usrid)
        {
            ReviseDBEntities con = new ReviseDBEntities();
            var reqRate          = con.userCatReqs.Find(reqid, usrid).rate;
            var ShowView         = new ReqRate()
            {
                reqvote = reqRate ?? 0
            };

            return(ShowView);
        }
Пример #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            ReviseDBEntities con  = new ReviseDBEntities();
            project          proj = con.projects.Find(id);
            var prjusr            = con.projUsers.Where(p => p.projid == id).ToList();

            //removes the users from the project
            if (prjusr != null)
            {
                foreach (var prj in prjusr)
                {
                    con.projUsers.Remove(prj);
                }
            }
            //remove all project categories
            var prjcat = con.projCats.Where(p => p.projId == id).ToList();

            foreach (var prj in prjcat)
            {
                con.projCats.Remove(prj);
            }
            //remove all project requirements
            var Projreq     = con.requirements.Where(p => p.projid == id).ToList();
            var Projreqvote = con.userCatReqs.ToList();

            if (Projreq != null)
            {
                foreach (var req in Projreq)
                {
                    foreach (var vote in Projreqvote)
                    {
                        if (vote.reqId == req.reqId)
                        {
                            con.userCatReqs.Remove(vote);
                        }
                    }
                    con.requirements.Remove(req);
                }
            }

            var message = con.messages.Where(p => p.projId == id).ToList();

            if (message != null)
            {
                foreach (var msg in message)
                {
                    con.messages.Remove(msg);
                }
            }

            con.projects.Remove(proj);
            con.SaveChanges();
            return(RedirectToAction("ProjectMain", "Project"));
        }
Пример #13
0
        public ActionResult EditCategory(int?id, string catname, int?totalLimit)
        {
            //checks if there are empty fields
            try
            {
                if (string.IsNullOrEmpty(catname) || totalLimit == null)
                {
                    TempData["EmptyFields"] = "One or more fields are empty";
                    return(RedirectToAction("EditCategory", "Category"));
                }
            }
            catch
            {
                TempData["FailedVote"] = "Unknown error occurred!";
                return(RedirectToAction("EditCategory", "Category"));
            }

            //gets category information from the DB
            ReviseDBEntities con = new ReviseDBEntities();
            var CatName          = con.categories.Find(id).CatName;
            int projid           = Convert.ToInt32(Session["projectid"]);
            var CatLimit         = con.projCats.Where(c => c.catId == id).SingleOrDefault(p => p.projId == projid).totalLimit ?? 0;

            // checks if there were no changes, checks if the category already exist
            try
            {
                if (CatName == catname && CatLimit == totalLimit)
                {
                    TempData["NoChanges"] = "No changes made";
                    return(RedirectToAction("CategoryMain", "Category", new { id = projid, name = Session["projectName"].ToString() }));
                }
                if (CatName != catname && con.projCats.Where(p => p.projId == projid).Any(c => c.category.CatName == catname))
                {
                    TempData["CatExist"] = "Category with this name already exist";
                    return(RedirectToAction("EditCategory", "Category", new { id = id, projid = projid }));
                }
            }
            catch
            {
                TempData["Unknown"] = "Unknown error occurred!";
                return(RedirectToAction("EditCategory", "Category", new { id = id, projid = projid }));
            }

            //save changes to the DB
            if (ModelState.IsValid)
            {
                con.categories.Find(id).CatName = catname;
                con.projCats.Where(c => c.catId == id).SingleOrDefault(p => p.projId == projid).totalLimit = totalLimit;
                con.SaveChanges();
                return(RedirectToAction("CategoryMain", "Category", new { id = projid, name = Session["projectName"].ToString() }));
            }
            return(RedirectToAction("CategoryMain", "Category", new { id = projid, name = Session["projectName"].ToString() }));
        }
Пример #14
0
 public static user GetUser()
 {
     using (var con = new ReviseDBEntities())
     {
         string userId = GetUserId();
         if (!string.IsNullOrEmpty(userId))
         {
             return((from x in con.users where x.userid == userId select x).ToList().FirstOrDefault());
         }
         return(new user());
     }
 }
        /// <summary>
        /// function that create view for gamification choice
        /// </summary>
        /// <param name="id">game id</param>
        /// <returns>returns updated model to show in the view</returns>
        public Gamfication GameView(int?id)
        {
            ReviseDBEntities con = new ReviseDBEntities();
            var gRepo            = new GameRepository();
            var ShowView         = new Gamfication()
            {
                projname     = con.projects.Find(id).ProjName,
                Gamification = gRepo.GetGame()
            };

            return(ShowView);
        }
Пример #16
0
        public ActionResult Requirement(string reqname, string reqdesc)
        {
            //gets the project and category id
            int projId = Convert.ToInt32(Session["projectid"]);
            int catId  = Convert.ToInt32(Session["Catid"]);

            //check if no requirement created
            try
            {
                if (string.IsNullOrEmpty(reqname) || string.IsNullOrEmpty(reqdesc))
                {
                    TempData["NoReq"] = "No requirement created";
                    return(RedirectToAction("CategoryMain", "Category", new { id = projId, name = Session["projectName"].ToString() }));
                }
            }
            catch
            {
                TempData["FailedReq"] = "Unknown error occurred!";
                return(RedirectToAction("Requirement", "Category"));
            }

            //if requirement created, adding it to the DB
            if (ModelState.IsValid)
            {
                ReviseDBEntities con = new ReviseDBEntities();
                if (Convert.ToInt32(Session["ReqExisit"]) == 0)
                {
                    var req = new requirement()
                    {
                        reqName     = reqname,
                        description = reqdesc,
                        projid      = projId,
                        catid       = catId
                    };

                    con.requirements.Add(req);
                }
                else
                {
                    int id = Convert.ToInt32(Session["ReqId"]);
                    con.requirements.SingleOrDefault(r => r.reqId == id).reqName     = reqname;
                    con.requirements.SingleOrDefault(r => r.reqId == id).description = reqdesc;
                }

                con.SaveChanges();

                return(RedirectToAction("Requirement", "Category"));
            }

            return(RedirectToAction("Requirement", "Category"));
        }
        /// <summary>
        /// function that create view for requirement page
        /// </summary>
        /// <param name="id">requirement id</param>
        /// <returns>returns updated model to show in the view</returns>
        public Categories Requirement(int id)
        {
            ReviseDBEntities con  = new ReviseDBEntities();
            string           req  = con.requirements.SingleOrDefault(r => r.reqId == id).reqName;
            string           desc = con.requirements.SingleOrDefault(r => r.reqId == id).description;
            var ShowView          = new Categories()
            {
                reqid   = id,
                reqname = req,
                reqdesc = desc
            };

            return(ShowView);
        }
Пример #18
0
        public ActionResult Registration(string firstname, string lastname, string UserId, string username, string phonenum, string EmailID, string password, string pic, Nullable <System.DateTime> DateOfBirth)
        {
            if (string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(lastname) || string.IsNullOrEmpty(username) ||
                string.IsNullOrEmpty(EmailID) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(UserId) || string.IsNullOrEmpty(phonenum)) //checks if one of the filldes is empty
            {
                TempData["EmptyFildes"] = "One or more fields is missing, Please fill all blank fields";
                return(RedirectToAction("Registration", "Authentication"));
            }

            if (string.IsNullOrEmpty(pic))    //if no picture provided, assign the default
            {
                pic = "https://he.gravatar.com/userimage/138919762/622efbcbeb0e8cea9b64cf6e8bffffc0.jpg";
            }

            #region Save to Database
            try
            {
                using (var con = new ReviseDBEntities())
                {
                    var isUserExists = con.users.Where(u => u.UserName == username || u.Email == EmailID || u.userid == UserId).Any();

                    if (!isUserExists)  //creat new user
                    {
                        var user = new user
                        {
                            Email    = EmailID,
                            fname    = firstname,
                            lname    = lastname,
                            password = password,
                            userid   = UserId,
                            UserName = username,
                            birthday = DateOfBirth,
                            PhoneNum = phonenum,
                            pic      = pic
                        };
                        con.users.Add(user);  //save the user in the DB
                        con.SaveChanges();
                        #endregion
                        return(RedirectToAction("Login", "Authentication"));
                    }
                    TempData["Exists"] = "User already exists!";
                    return(RedirectToAction("Registration", "Authentication"));
                }
            }
            catch
            {
                TempData["Unknown"] = "Unknown error occurred!!";
                return(RedirectToAction("Registration", "Authentication"));
            }
        }
Пример #19
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                TempData["emptyIDprj"] = "An error occurred while trying to delete";
                return(RedirectToAction("ProjectMain", "Project"));
            }
            var repo              = new MainRepository();
            var Main              = repo.ProjView(id);
            ReviseDBEntities con  = new ReviseDBEntities();
            List <projUser>  proj = con.projUsers.Where(p => p.projid == id).ToList();

            ViewBag.members = proj;
            return(View(Main));
        }
Пример #20
0
        internal static bool IsLoggedIn()
        {
            string userId;

            using (var con = new ReviseDBEntities())
            {
                userId = GetUserId();
                var users = con.users.Where(u => u.userid == userId).ToList();
                if (users.First().isConnected == 1)
                {
                    return(true);
                }
                return(false);
            }
        }
Пример #21
0
 /// <summary>
 /// logs out the connected user
 /// </summary>
 /// <returns>redirect to the log-in screen</returns>
 public ActionResult Logout()
 {
     try
     {
         ReviseDBEntities con = new ReviseDBEntities();
         con.users.Find(Session["userid"].ToString()).isConnected = 0;
         con.SaveChanges();
         FormsAuthentication.SignOut();
         return(RedirectToAction("Login", "Authentication"));
     }
     catch
     {
         throw;
     }
 }
        /// <summary>
        /// function that create view for category main
        /// </summary>
        /// <param name="catid">category id</param>
        /// <param name="projid">project id</param>
        /// <returns>returns updated model to show in the view</returns>
        public CreateCategory CatEditView(int?catid, int projid)
        {
            ReviseDBEntities con = new ReviseDBEntities();
            int    cat           = con.categories.Find(catid).CatId;
            int    limit         = con.projCats.Where(c => c.catId == catid).SingleOrDefault(p => p.projId == projid).totalLimit ?? 0;
            string catName       = con.categories.Find(catid).CatName;
            var    ShowView      = new CreateCategory()
            {
                catid      = cat,
                catname    = catName,
                totalLimit = limit,
                projid     = projid
            };

            return(ShowView);
        }
Пример #23
0
        public ActionResult Vote(int reqvote)
        {
            //gets the project, category, user and requirement id
            int    projId  = Convert.ToInt32(Session["projectid"]);
            int    catId   = Convert.ToInt32(Session["Catid"]);
            int    reqId   = Convert.ToInt32(Session["ReqId"]);
            int    IsExist = Convert.ToInt32(Session["ReqExisit"]);
            string userID  = Session["userid"].ToString();

            ReviseDBEntities con = new ReviseDBEntities();

            //checks if there is no vote
            try
            {
                if (reqvote == 0)
                {
                    TempData["EmptyVote"] = "No vote was set";
                    return(RedirectToAction("Vote", "Category"));
                }
            }
            catch
            {
                TempData["FailedVote"] = "Unknown error occurred!";
                return(RedirectToAction("Vote", "Category"));
            }

            //updaets the user vote
            if (con.userCatReqs.Find(reqId, userID) != null)
            {
                con.userCatReqs.Find(reqId, userID).rate = reqvote;
            }
            else
            {
                userCatReq RateReq = new userCatReq()
                {
                    usrid = userID,
                    reqId = reqId,
                    rate  = reqvote
                };
                con.userCatReqs.Add(RateReq);
            }


            con.SaveChanges();

            return(RedirectToAction("Vote", "Category"));
        }
        /// <summary>
        /// function that creates view edit project
        /// </summary>
        /// <param name="id"> project id</param>
        /// <returns>returns updated model to show in the view</returns>
        public EditProject EditProjView(int?id)
        {
            ReviseDBEntities con = new ReviseDBEntities();      //connection to the DB
            var uRepo            = new AssignUserRepository();  //gets user list to assign
            var rRepo            = new RemoveUsers();           //gets user list to remove

            var ShowView = new EditProject()
            {
                AssignUser = uRepo.GetUsers(id),
                RemoveUser = rRepo.GetUsers(id),
                projid     = id ?? default(int),
                projname   = con.projects.Find(id).ProjName,
                projdesc   = con.projects.Find(id).description,
            };

            return(ShowView);
        }
Пример #25
0
        public ActionResult AssignMembers(IEnumerable <string> SelectedDepartment, IEnumerable <string> SelectedRole)
        {
            if (SelectedDepartment == null || SelectedRole == null)
            {
                return(Json(new { success = "Failed", error = "No department or role selected" }));
            }

            var              ChooseAssigndep  = SelectedDepartment.ToList();
            var              ChooseAssignrole = SelectedRole.ToList();
            List <user>      UsersToAssign    = (List <user>)Session["AssignList"];
            int              proj             = Convert.ToInt32(Session["IdProjectToAssign"]);
            ReviseDBEntities con = new ReviseDBEntities();

            //checks if department and role selected, if so- updating the role of the users in the project
            for (int i = 0; i < UsersToAssign.Count; i++)
            {
                if ((ChooseAssigndep.ElementAt(i) == "") || (ChooseAssignrole.ElementAt(i) == ""))
                {
                    return(Json(new { success = "Failed", error = "No department or role selected" }));
                }
                else
                {
                    int dep_id  = Int32.Parse(ChooseAssigndep.ElementAt(i));
                    int role_id = Int32.Parse(ChooseAssignrole.ElementAt(i));
                    var role    = con.roles.Where(r => r.RoleID == role_id);
                    var dep     = con.departments.Where(d => d.depId == dep_id);
                    var myId    = UsersToAssign[i].userid;
                    var uspr    = con.projUsers.Where(u => u.userid == myId).ToList();
                    foreach (var usr in uspr)
                    {
                        if (usr.projid == proj)
                        {
                            usr.department = dep.First();
                            usr.role1      = role.First();
                            usr.role       = role.First().RoleID;
                            usr.dep        = dep.First().depId;
                        }
                    }
                }
                con.SaveChanges();
            }

            return(RedirectToAction("CategoryMain", "Category", new { id = proj }));
            // return RedirectToAction("CategoryMain/" + Convert.ToInt32(Session["IdProjectToAssign"]) + "", "Category", new { id = proj });
        }
        /// <summary>
        /// function that shows the chat screen
        /// </summary>
        /// <param name="catid">category id</param>
        /// <param name="projid">project id</param>
        /// <returns>edirect to the chat screen</returns>
        public ActionResult Chat(int?catid, int?projid)
        {
            ReviseDBEntities con = new ReviseDBEntities();

            if (catid == null || projid == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            category cat  = con.categories.SingleOrDefault(c => c.CatId == catid);
            project  proj = con.projects.SingleOrDefault(p => p.ProjId == projid);
            //getting the specific project and category to open the chat for them
            int pid = proj.ProjId;
            int cid = cat.CatId;
            var prj = con.projUsers.Where(u => u.projid == proj.ProjId).ToList();

            if (cat == null)
            {
                return(HttpNotFound());
            }

            //getting the project members
            List <user> memberslist = new List <user>();

            foreach (var usr in prj)
            {
                memberslist.Add(con.users.SingleOrDefault(u => u.userid == usr.userid));
            }

            ViewBag.memberslist = memberslist; // the list of members that participant in this project pass via ViewBag to the view.
            ViewBag.catid       = catid;
            ViewBag.projid      = projid;

            Session["Catid"] = catid;
            string userId = Session["userid"].ToString();

            UserScoreCalc(userId);
            Session["UserScore"] = con.users.Find(userId).score;
            var showView = new Categories()
            {
                category = cat.CatName,
                status   = con.projCats.Find(pid, cid).status ?? 0
            };

            return(View(showView));
        }
        /// <summary>
        /// function that create view for personal file page
        /// </summary>
        /// <param name="id">user id</param>
        /// <returns>returns updated model to show in the view</returns>
        public UserRegestration PersonalFileView(string id)
        {
            ReviseDBEntities con = new ReviseDBEntities();
            var user             = con.users.Find(id);

            var ShowView = new UserRegestration()
            {
                UserId      = user.userid,
                UserName    = user.UserName,
                FirstName   = user.fname,
                LastName    = user.lname,
                Phonenum    = user.PhoneNum,
                EmailID     = user.Email,
                DateOfBirth = user.birthday ?? DateTime.Today.Date
            };

            return(ShowView);
        }
Пример #28
0
        /// <summary>
        /// function for assign role to uesrs in a project
        /// </summary>
        /// <param name="id">the project id</param>
        /// <returns></returns>
        public ActionResult AssignMembers(int?id)
        {
            List <user>      memberslist = new List <user>();
            ReviseDBEntities con         = new ReviseDBEntities();
            List <user>      Allusers    = new List <user>();
            var prj = con.projUsers.Where(u => u.projid == id).ToList();  //finding all the project uesrs

            foreach (var p in prj)
            {
                memberslist.Add(con.users.SingleOrDefault(u => u.userid == p.userid));   //creating a list from those users
            }
            ViewBag.memberslist   = memberslist;
            Session["AssignList"] = memberslist;

            var repo = new MainRepository();
            var Main = repo.CreateView();

            return(View(Main));
        }
 /// <summary>
 /// function that gets roles from the DB and add them to a list
 /// </summary>
 /// <returns>return list of roles</returns>
 public IEnumerable <SelectListItem> GetRole()
 {
     using (var context = new ReviseDBEntities())
     {
         List <SelectListItem> roles = context.roles.AsNoTracking()
                                       .OrderBy(n => n.RoleID)
                                       .Select(n =>
                                               new SelectListItem
         {
             Value = n.RoleID.ToString(),
             Text  = n.RoleName
         }).ToList();
         var RoleType = new SelectListItem()
         {
             Value = null,
             Text  = "--- select role ---"
         };
         roles.Insert(0, RoleType);
         return(new SelectList(roles, "Value", "Text"));
     }
 }
Пример #30
0
        /// <summary>
        /// function for exporting software requirement specification document
        /// </summary>
        /// <param name="id">the project id</param>
        /// <returns>shows the document</returns>
        public ActionResult ReqExport(int id)
        {
            ReviseDBEntities con = new ReviseDBEntities();
            int ProjectId        = id;

            ViewBag.MemberProjectList = con.projUsers.Where(p => p.projid == ProjectId).ToList();
            var req = con.requirements.Where(p => p.projid == ProjectId).ToList();

            Session["projectName"] = con.projects.SingleOrDefault(p => p.ProjId == id).ProjName;
            List <ReviseApplication.Models.Categories> list = new List <Categories>();

            foreach (var r in req)
            {
                ReviseApplication.Models.Categories cat = new ReviseApplication.Models.Categories();
                cat.category = r.category.CatName;
                cat.reqname  = r.reqName;
                cat.reqdesc  = r.description;
                list.Add(cat);
            }
            return(View(list));
        }