Ejemplo n.º 1
0
        /// <summary>
        /// Create project, set specified user as member of project
        /// </summary>
        /// <param name="project">project to create</param>
        /// <param name="personId">id of person who created project</param>
        public void CreateProject(Project project, int personId)
        {
            ICollection<ValidationResult> validationResults;

             if (project.TryValidate(out validationResults))
             {
                 ProjectDAL.CreateProject(project, personId);
             }
             else
             {
                 var ex = new ValidationException("");
                 ex.Data.Add("ValidationResults", validationResults);
                 throw ex;
             }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new project
        /// </summary>
        /// <param name="project">Project object</param>
        public void ProjectListView_InsertItem(Project project)
        {
            //Validate
            TryUpdateModel(project);
            if (ModelState.IsValid)
            {
                //Try to create
                try
                {
                    Service.CreateProject(project, PersonId);
                    Page.SetTemp("message", "Project was created.");
                    Response.RedirectToRoute("Projects");
                    Context.ApplicationInstance.CompleteRequest();
                }
                catch (Exception)
                {
                    ModelState.AddModelError(string.Empty, "An unexpected error occured while creating the project.");
                }

            }
        }