/// <summary>
 /// Updates the project.
 /// </summary>
 /// <param name="project">The project.</param>
 public static void UpdateProject(PM_Projects project)
 {
     try
     {
         int rowsAffected = GetSynegyRMSInstance().SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ActionResult NewProject(FormCollection form)
        {
            try
            {
                PM_Projects Project = new PM_Projects();
                Project.ProjectCode = form["txtCode"].ToString();
                Project.ProjectName = form["txtprojectname"].ToString();
                Project.ProjectStartDate = Convert.ToDateTime(form["projectstartdate"]);
                Project.ProjectEndDate = Convert.ToDateTime(form["projectenddate"]);
                Project.Description = form["txtDescription"].ToString().Trim();
                Project.PM_Status = SynergyService.GetProjectStatusById(1);
                Project.PM_Types = SynergyService.GetProjectTypebyId(Convert.ToInt32(form["ddProTypes"].ToString()));
                SynergyService.SaveProject(Project);

                if (Project.ProjectId>0)
                {
                    ViewData["status"] = "Success";
                    ViewData["msg"] = String.Format("New Project {0} Successfully Created." , form["txtprojectname"].ToString());
                }
                else
                {
                    ViewData["status"] = "Error";
                    ViewData["msg"] = "Error in Project Creation.";
                }
            }
            catch
            {
                ViewData["status"] = "Error";
                ViewData["msg"] = "Error in Project Creation.";
            }
            List<PM_Types> allProTypes = SynergyService.GetAllTypes();
            SelectList list = new SelectList(allProTypes, "TypeId", "TypeName");

            ViewData["ProTypes"] = GetProjectTypes();
            return View("NewProject");
        }
 /// <summary>
 /// Saves the project.
 /// </summary>
 /// <param name="project">The project.</param>
 public static void SaveProject(PM_Projects project)
 {
     try
     {
         GetSynegyRMSInstance().AddToPM_Projects(project);
         GetSynegyRMSInstance().SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
        public static List<PM_Projects> getUserProjects(string userkey)
        {
            List<PM_ProjectResources> ProjectResList = null;
            List<PM_Projects> ProjectList = new List<PM_Projects>();
            PM_Projects objProject = null;

            MembershipUser edituser = Membership.GetUser(new Guid(userkey));

            IQueryable<PM_ProjectResources> projectQuery = from p in GetSynegyRMSInstance().PM_ProjectResources
                                                           where p.aspnet_Users.UserName == edituser.UserName
                                                           select p;

            ProjectResList = projectQuery.ToList();

            foreach (PM_ProjectResources objResources in ProjectResList)
            {
                PM_Projects project = new PM_Projects();

                objProject = new PM_Projects();
                objResources.PM_ProjectsReference.Load();

                ProjectList.Add(objResources.PM_Projects);

                //objResources.UM_UsersReference.Load();
                //int aa = single1.T_User.UserId;
            }

            return ProjectList;
        }