Exemplo n.º 1
0
        public ActionResult Create(User user)
        {
            if (Session["LoggedUser"] == null)
            {
                return(RedirectToAction("Login", "User"));
            }
            // Model Validation
            if (ModelState.IsValid)
            {
                if (user.ImageFile != null)
                {
                    string fileName = Path.GetFileNameWithoutExtension(user.ImageFile.FileName);
                    string fileExt  = Path.GetExtension(user.ImageFile.FileName);
                    fileName   = fileName + DateTime.Now.ToString("yymmssfff") + fileExt;
                    user.photo = "~/Images/" + fileName;
                    fileName   = Path.Combine(Server.MapPath("~/Images"), fileName);
                    user.ImageFile.SaveAs(fileName);
                }
                using (PMEntities context = new PMEntities())
                {
                    context.Users.Add(user);
                    context.SaveChanges();
                }
                ViewBag.Message = "Created Successfully";
            }
            else
            {
                ViewBag.Error = "Invalid Request";
            }

            return(View());
        }
Exemplo n.º 2
0
        public ActionResult GetUserProfile(int id)
        {
            var loggedUser = (User)Session["LoggedUser"];

            using (PMEntities context = new PMEntities())
            {
                if (context.Users.Any(u => u.Id == loggedUser.Id))
                {
                    User   userprofile       = context.Users.Find(loggedUser.Id);
                    double pendingCount      = context.projects.Count(p => (p.status == 0 && p.owner_id == loggedUser.Id));
                    double deliveredCount    = context.projects.Count(p => (p.status == 1 && p.owner_id == loggedUser.Id));
                    double notdeliveredCount = context.projects.Count(p => (p.status == 2 && p.owner_id == loggedUser.Id));
                    double inprogress        = context.projects.Count(p => (p.status == 5 && p.owner_id == loggedUser.Id));
                    double total             = pendingCount + deliveredCount + notdeliveredCount + inprogress;
                    if (total == 0)
                    {
                        total = 1;
                    }
                    double[] customerDashboard = { (pendingCount / total) * 100, (deliveredCount / total) * 100, (notdeliveredCount / total) * 100, (inprogress / total) * 100 };
                    return(Json(new { status = "200", data = userprofile, dashboardData = customerDashboard, displaySweetAlert = false }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { status = "404", data = "", message = "User Not found", displaySweetAlert = false }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Exemplo n.º 3
0
        public static List <stakeholder> GetStakeholderFullName()
        {
            var stakeholderList = new List <stakeholder>();

            using (var db = new PMEntities())
            {
                (from p in db.stakeholders
                 orderby p.stakeholder_id
                 select new
                {
                    Id = p.stakeholder_id,
                    Name = p.stakeholder_full_name
                }).ToList()
                .ForEach(f => stakeholderList.Add(new stakeholder
                {
                    stakeholder_id        = f.Id,
                    stakeholder_full_name = f.Name
                }));

                //if (stakeholderList.Any() == true)
                //{
                //    stakeholderList.Insert(0, new stakeholder());
                //}
            }
            return(stakeholderList);
        }
Exemplo n.º 4
0
        public ActionResult EditProfile(User newdata)
        {
            ModelState.Clear();
            var loggedUser = (User)Session["LoggedUser"];

            using (PMEntities context = new PMEntities())
            {
                if (context.Users.Any(u => u.Id == loggedUser.Id))
                {
                    try
                    {
                        User editeduser = context.Users.Find(loggedUser.Id);
                        editeduser.first_name      = newdata.first_name;
                        editeduser.last_name       = newdata.last_name;
                        editeduser.email           = newdata.email;
                        editeduser.jop_description = newdata.jop_description;
                        editeduser.type            = editeduser.type;
                        editeduser.password        = editeduser.password;
                        editeduser.ConfirmPassword = editeduser.password;
                        editeduser.mobile          = newdata.mobile;
                        context.SaveChanges();
                        return(Json(new { status = "200", data = editeduser, displaySweetAlert = true, message = "User Edited Successfully" }, JsonRequestBehavior.AllowGet));
                    }
                    catch (Exception ex)
                    {
                        return(Json(new { status = "400", data = " ", displaySweetAlert = true, message = ex.Message }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json(new { status = "404", data = "", message = "User Not found", displaySweetAlert = false }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Exemplo n.º 5
0
        public ActionResult AddProject(project newproject)
        {
            var loggedUser = (User)Session["LoggedUser"];

            using (PMEntities context = new PMEntities())
            {
                int maxPj = context.projects.Count();
                if (maxPj > 0)
                {
                    project last = context.projects.OrderByDescending(p => p.Id).FirstOrDefault();
                    maxPj = last.Id;
                }
                project pj = new project
                {
                    Id          = maxPj + 1,
                    name        = newproject.name,
                    status      = 0,
                    description = newproject.description,
                    owner_id    = loggedUser.Id
                };
                context.projects.Add(pj);
                context.SaveChanges();
                return(Json(new { status = "200", data = pj, displaySweetAlert = true, message = "Project Added Successfully" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 6
0
 public ActionResult DeleteProject(int id)
 {
     using (PMEntities context = new PMEntities())
     {
         if (context.projects.Any(p => p.Id == id))
         {
             List <Int32> allowedStatusToDelete = new List <int>();
             allowedStatusToDelete.Add(0); allowedStatusToDelete.Add(3); allowedStatusToDelete.Add(4);
             project pj = context.projects.Find(id);
             if (allowedStatusToDelete.Contains((int)pj.status))
             {
                 context.projects.Remove(pj);
                 context.SaveChanges();
                 return(Json(new { status = "200", data = 1, displaySweetAlert = true, message = "Project Deleted Successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { status = "444", data = 0, displaySweetAlert = false, message = "You Can't delete this project" }, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             return(Json(new { status = "404", data = 0, message = "project not found", displaySweetAlert = false }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Exemplo n.º 7
0
        public ActionResult AdminAddProject(project newproject)
        {
            using (PMEntities context = new PMEntities())
            {
                int maxPj = context.projects.Count();
                if (maxPj > 0)
                {
                    project last = context.projects.OrderByDescending(p => p.Id).FirstOrDefault();
                    maxPj = last.Id;
                }
                project pj = new project
                {
                    Id          = maxPj + 1,
                    name        = newproject.name,
                    status      = 0,
                    description = newproject.description,
                    owner_id    = newproject.owner_id
                };
                context.projects.Add(pj);
                context.SaveChanges();

                var users = context.Users.Where(u => u.type == "customer").ToList();
                ViewBag.users = users;


                ViewBag.Message = "Project Created Successfully";
                return(View());
            }
        }
Exemplo n.º 8
0
 public bool IsEmailExist(string target_email)
 {
     using (PMEntities dc = new PMEntities())
     {
         var v = dc.Users.Where(a => a.email == target_email).FirstOrDefault();
         return(v != null);
     }
 }
Exemplo n.º 9
0
 public ActionResult AddProjectWorker(Team team)
 {
     using (PMEntities context = new PMEntities())
     {
         context.Teams.Add(team);
         context.SaveChanges();
         return(Json(new { delteam = team, status = "200", data = 1, message = "project not found", displaySweetAlert = true }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 10
0
 public ActionResult AdminAddProject()
 {
     using (PMEntities context = new PMEntities())
     {
         var users = context.Users.Where(u => u.type == "customer").ToList();
         ViewBag.users = users;
         return(View());
     }
 }
Exemplo n.º 11
0
 public ActionResult ChangeStatus(project editData)
 {
     using (PMEntities context = new PMEntities())
     {
         project pj = context.projects.Find(editData.Id);
         pj.status = editData.status;
         context.SaveChanges();
         return(Json(new { status = "200", data = pj }));
     }
 }
Exemplo n.º 12
0
        public ActionResult Delete(int id)
        {
            using (PMEntities context = new PMEntities())
            {
                var project = context.projects.Single(c => c.Id == id);
                context.projects.Remove(project);
                context.SaveChanges();

                return(RedirectToAction("PmDashboard", "Home"));
            }
        }
Exemplo n.º 13
0
        public ActionResult ChangeStatusD(int id)
        {
            using (PMEntities context = new PMEntities())
            {
                var project = context.projects.Single(c => c.Id == id);
                project.status = 1;
                context.SaveChanges();
            }

            return(RedirectToAction("PmDashboard", "Home"));
        }
Exemplo n.º 14
0
        public ActionResult Edit(int id)
        {
            if (Session["LoggedUser"] == null)
            {
                return(RedirectToAction("Login", "User"));
            }

            using (PMEntities context = new PMEntities())
            {
                var users = context.Users.Where(u => u.Id == id).FirstOrDefault();
                return(View(users));
            }
        }
Exemplo n.º 15
0
        public ActionResult SaveComment(pj_manager_request req)
        {
            var loggedUser = (User)Session["LoggedUser"];

            req.project_manager_id = loggedUser.Id;

            using (PMEntities context = new PMEntities())
            {
                context.pj_manager_request.Add(req);
                context.SaveChanges();
            }
            return(RedirectToAction("PmDashboard", "Home"));
        }
Exemplo n.º 16
0
        // view all users
        public ActionResult Index()
        {
            if (Session["LoggedUser"] == null)
            {
                return(RedirectToAction("Login", "User"));
            }
            User current_user = (User)Session["LoggedUser"];
            int  user_id      = current_user.Id;

            using (PMEntities context = new PMEntities())
            {
                var users = context.Users.Where(u => u.Id != user_id).ToList();
                return(View(users));
            }
        }
Exemplo n.º 17
0
        public ActionResult Registration(User user)
        {
            try
            {
                bool   Status  = false;
                string message = "";
                //
                // Model Validation
                if (ModelState.IsValid)
                {
                    #region //Email is already Exist
                    var isExist = IsEmailExist(user.email);
                    if (isExist)
                    {
                        ModelState.AddModelError("EmailExist", "Email already exist");
                        return(View(user));
                    }
                    #endregion
                    #region to encrypt the password
                    // user.password = Crypto.Hash(user.password);
                    #endregion
                    #region Save to Database
                    using (PMEntities dc = new PMEntities())
                    {
                        dc.Users.Add(user);
                        dc.SaveChanges();
                        Status = true;
                    }
                    #endregion
                    Session["LoggedUserID"] = user.Id.ToString();
                    Session["LoggedUser"]   = user;
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    message = "Invalid Request";
                }

                ViewBag.Message = message;
                ViewBag.Status  = Status;
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Invalid Request";
            }

            return(View(user));
        }
Exemplo n.º 18
0
 public ActionResult GetProject(int id)
 {
     using (PMEntities context = new PMEntities())
     {
         if (context.projects.Any(p => p.Id == id))
         {
             project pj = context.projects.Find(id);
             pj.project_manager = context.Users.Find(pj.project_manager_id);
             return(Json(new { status = "200", data = pj, displaySweetAlert = false }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = "404", data = "", message = "project not found", displaySweetAlert = false }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Exemplo n.º 19
0
        public ActionResult Delete(int id)
        {
            if (Session["LoggedUser"] == null)
            {
                return(RedirectToAction("Login", "User"));
            }
            using (PMEntities context = new PMEntities())
            {
                var users = context.Users.FirstOrDefault(u => u.Id == id);
                context.Users.Remove(users);
                context.SaveChanges();
            }

            ViewBag.Message = "Deleted Successfully";
            return(RedirectToAction("Index"));
        }
Exemplo n.º 20
0
 public ActionResult AssignUser(pj_manager_request request)
 {
     using (PMEntities context = new PMEntities())
     {
         if (context.projects.Any(p => p.Id == request.project_id))
         {
             project pj = context.projects.Find(request.project_id);
             pj.project_manager_id = request.project_manager_id;
             pj.status             = 5;
             context.SaveChanges();
             return(Json(new { status = "200", data = request, displaySweetAlert = true, message = "Project Assigned Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = "404", data = "", message = "project not found", displaySweetAlert = false }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Exemplo n.º 21
0
 public ActionResult EditProject(project editdata)
 {
     using (PMEntities context = new PMEntities())
     {
         if (context.projects.Any(p => p.Id == editdata.Id))
         {
             project pj = context.projects.Find(editdata.Id);
             pj.name        = editdata.name;
             pj.description = editdata.description;
             context.SaveChanges();
             return(Json(new { status = "200", data = pj, displaySweetAlert = true, message = "Project Edited Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = "404", data = "", message = "project not found", displaySweetAlert = false }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Exemplo n.º 22
0
 public static void UpdateProject(proj_info proj_info)
 {
     using (var db = new PMEntities())
     {
         var existingProjInfo = db.proj_info.Find(proj_info.proj_info_id);
         if (existingProjInfo != null)
         {
             // entity already in the context
             var attachedEntry = db.Entry(existingProjInfo);
             attachedEntry.CurrentValues.SetValues(proj_info);
         }
         else
         {
             // Since we don't have it in db, this is a simple add.
             db.proj_info.Add(proj_info);
         }
     }
 }
Exemplo n.º 23
0
        public ActionResult Edit(User user)
        {
            if (Session["LoggedUser"] == null)
            {
                return(RedirectToAction("Login", "User"));
            }
            // Model Validation
            if (ModelState.IsValid)
            {
                if (user.ImageFile != null)
                {
                    string fileName = Path.GetFileNameWithoutExtension(user.ImageFile.FileName);
                    string fileExt  = Path.GetExtension(user.ImageFile.FileName);
                    fileName   = fileName + DateTime.Now.ToString("yymmssfff") + fileExt;
                    user.photo = "~/Images/" + fileName;
                    fileName   = Path.Combine(Server.MapPath("~/Images"), fileName);
                    user.ImageFile.SaveAs(fileName);
                }

                using (PMEntities context = new PMEntities())
                {
                    User updated_user = context.Users.FirstOrDefault(u => u.Id == user.Id);
                    updated_user.first_name = user.first_name;
                    updated_user.last_name  = user.last_name;

                    updated_user.jop_description = user.jop_description;

                    updated_user.type = user.type;

                    updated_user.password        = user.password;
                    updated_user.ConfirmPassword = user.ConfirmPassword;
                    updated_user.photo           = user.photo;
                    updated_user.mobile          = user.mobile;
                    updated_user.email           = user.email;


                    context.SaveChanges();
                    ViewBag.Message = "Edit Successfully";
                    return(View(user));
                }
            }
            ViewBag.Error = "Invaild Request";
            return(View(user));
        }
Exemplo n.º 24
0
        public ActionResult PmDashboard()
        {
            IDictionary <int, string> status = new Dictionary <int, string>();

            status[0] = "Pending";
            status[1] = "Delivered";
            status[2] = "Not Delivered";
            status[3] = "Approved";
            status[4] = "Decline";
            status[5] = "In Progress";

            ViewBag.status = status;

            using (PMEntities context = new PMEntities())
            {
                var projects = context.projects.Where(c => c.status == 3).ToList();
                return(View(projects));
            }
        }
Exemplo n.º 25
0
 public ActionResult Login(User u)
 {
     // this action is for handle post (login)
     //if (ModelState.IsValid) // this is check validity
     //{
     using (PMEntities dc = new PMEntities())
     {
         var v = dc.Users.Where(a => a.email.Equals(u.email) && a.password.Equals(u.password)).FirstOrDefault();
         if (v != null)
         {
             Session["LogedUserID"] = v.Id.ToString();
             Session["LoggedUser"]  = v;
             return(RedirectToAction("Index", "Home"));
         }
     }
     //}
     ViewBag.Error = "Invalid User Name Or password";
     return(View(u));
 }
Exemplo n.º 26
0
 public ActionResult GetPjManagerRequests(int id)
 {
     using (PMEntities context = new PMEntities())
     {
         if (context.pj_manager_request.Any(p => p.project_id == id))
         {
             var requests = context.pj_manager_request.Where(p => (p.project_id == id)).ToList();
             foreach (var req in requests)
             {
                 req.project_manager = context.Users.FirstOrDefault(u => u.Id == req.project_manager_id);
             }
             return(Json(new { status = "200", data = requests, displaySweetAlert = false }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = "404", data = "", message = "there's no user assigned", displaySweetAlert = false }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Exemplo n.º 27
0
        public static List <proj_status> GetStatusList()
        {
            var statusList = new List <proj_status>();

            using (var db = new PMEntities())
            {
                (from p in db.proj_status
                 orderby p.proj_status_id ascending
                 select new
                {
                    Id = p.proj_status_id,
                    Name = p.proj_status_desc
                }).ToList()
                .ForEach(f => statusList.Add(new proj_status
                {
                    proj_status_id   = f.Id,
                    proj_status_desc = f.Name
                }));
            }
            return(statusList);
        }
Exemplo n.º 28
0
        public static List <proj_type> GetProjectTypeList()
        {
            var projectTypeList = new List <proj_type>();

            using (var db = new PMEntities())
            {
                (from p in db.proj_type
                 orderby p.project_type_id ascending
                 select new
                {
                    Id = p.project_type_id,
                    Name = p.project_type_name
                }).ToList()
                .ForEach(f => projectTypeList.Add(new proj_type
                {
                    project_type_id   = f.Id,
                    project_type_name = f.Name
                }));
            }
            return(projectTypeList);
        }
Exemplo n.º 29
0
        public static List <proj_log_code> GetProjectLogCodeDescription()
        {
            var projcodedescList = new List <proj_log_code>();

            using (var db = new PMEntities())
            {
                (from p in db.proj_log_code
                 orderby p.proj_log_code_id ascending
                 where p.is_auto == false
                 select new
                {
                    Id = p.proj_log_code_id,
                    Name = p.proj_log_code_desc
                }).ToList()
                .ForEach(f => projcodedescList.Add(new proj_log_code
                {
                    proj_log_code_id   = f.Id,
                    proj_log_code_desc = f.Name
                }));
            }
            return(projcodedescList);
        }
Exemplo n.º 30
0
        public ActionResult CreateTeam(int Id)
        {
            using (PMEntities context = new PMEntities())
            {
                var allUsers = context.Users.Where(c => c.type == "je" || c.type == "tl").ToList();

                var notAssignedUsers = new List <User>();


                foreach (var user in allUsers)
                {
                    if (context.Teams.Where(c => c.user_id == user.Id && c.project_id == Id).FirstOrDefault() == null)
                    {
                        notAssignedUsers.Add(user);
                    }
                }

                ViewBag.project = context.projects.Single(c => c.Id == Id);

                return(View(notAssignedUsers));
            }
        }
Exemplo n.º 31
0
 public static void UpdateProject(proj_info proj_info)
 {
     using (var db = new PMEntities())
     {
         var existingProjInfo = db.proj_info.Find(proj_info.proj_info_id);
         if (existingProjInfo != null)
         {
             // entity already in the context
             var attachedEntry = db.Entry(existingProjInfo);
             attachedEntry.CurrentValues.SetValues(proj_info);
         }
         else
         {
             // Since we don't have it in db, this is a simple add.
             db.proj_info.Add(proj_info);
         }
     }
 }