예제 #1
0
        public ActionResult CreateNewProject(int?id)
        {
            var newProject = new CreateProjectStatementViewModel
            {
                CourseId        = id,
                ProjectDeadline = DateTime.Now
            };

            return(View("CreateOrUpdateProject", newProject));
        }
예제 #2
0
        public ActionResult EditProjectStatement(int id)
        {
            var projectStatement = _context.ProjectsStatement.SingleOrDefault(c => c.ProjectStatementId == id);

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

            var updateProjectStatement = new CreateProjectStatementViewModel
            {
                CourseId         = projectStatement.CourseId,
                ProjectDeadline  = projectStatement.ProjectDeadline,
                ProjectStatement = projectStatement
            };

            return(View("CreateOrUpdateProject", updateProjectStatement));
        }
예제 #3
0
        public ActionResult Save([FromUri] int id, CreateProjectStatementViewModel newProject)
        {
            var projectStatement = newProject.ProjectStatement;

            projectStatement.CourseId = id;
            if (projectStatement.ProjectStatementId == 0)
            {
                projectStatement.ProjectCreationDate = DateTime.Now;
                _context.ProjectsStatement.Add(projectStatement);
            }
            else
            {
                var projectInDb = _context.ProjectsStatement.Single(c => c.ProjectStatementId == projectStatement.ProjectStatementId);
                projectInDb.ProjectName        = projectStatement.ProjectName;
                projectInDb.ProjectDescription = projectStatement.ProjectDescription;
                projectInDb.ProjectMaxSize     = projectStatement.ProjectMaxSize;
                projectInDb.ProjectDeadline    = projectStatement.ProjectDeadline;
            }
            _context.SaveChanges();
            return(RedirectToAction("ProjectStatementDetails/" + id, "ProjectsStatement"));
        }