コード例 #1
0
        public IActionResult CreateProject(CreateProjectModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(View(new CreateProjectModel())); // todo: tell user why the input is invalid.
            }

            Guid orgId = new(User.ClaimValue(UserClaimsIndex.OrganizationModel));

            ProjectModel proj = new()
            {
                Name             = model.Name,
                Deadline         = model.Deadline,
                Description      = model.Description,
                ParentIdTreePath = model.ParentIdTreePath,
                Priority         = model.Priority,
                Status           = model.Status
            };

            _db.CreateProject(proj, orgId);

            _db.CreateAssignment(new AssignmentModel()
            {
                AssigneeAccess    = UserPosition.ADMIN, // todo: no admins for projects? should the creator be a manager?
                AssigneeId        = new Guid(User.ClaimValue(UserClaimsIndex.Id)),
                OrganizationId    = orgId,
                ProjectIdTreePath = proj.IdTreePath
            });

            return(ProjectHome(proj.IdTreePath));
        }