예제 #1
0
        public ActionResult Create(ProjectCreateForm collection)
        {
            try
            {
                if ((ModelState.IsValid) && (UserSession.CurrentUser.AdminId != null))
                {
                    EmployeeService repoemployee   = new EmployeeService();
                    Employee        Projectmanager = repoemployee.Get().Where <Employee>((emp) => emp.Email == collection.ProjectManager).FirstOrDefault();
                    if (Projectmanager != null)
                    {
                        ProjectService repo = new ProjectService();
                        Project        d    = repo.Insert(new Project(
                                                              collection.Name,
                                                              collection.Description,
                                                              collection.StartDate,
                                                              collection.EndDate,
                                                              (int)UserSession.CurrentUser.AdminId,
                                                              Projectmanager.Id));
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(View(collection));
                    }
                }

                return(View(collection));
            }
            catch
            {
                return(View(collection));
            }
        }
예제 #2
0
        /// <summary>
        /// 建立项目
        /// </summary>
        /// <returns>可能为null</returns>
        public static Project CreateProject()
        {
            ProjectCreateForm c = new ProjectCreateForm();

            c.ShowDialog();
            return(c.Project);
        }