public async Task <IActionResult> Create(ProjectModel projectModel) { var RecordId = string.Empty; try { RecordId = await _projectStorage.Add(projectModel); } catch (KeyNotFoundException KE) { return(new NotFoundResult()); } catch (Exception exception) { return(StatusCode(500, exception.Message)); } return(StatusCode(201, new CreateProjectResponse() { Id = RecordId })); }
/// <summary> /// Saves the specified project aggregate root. /// </summary> /// <param name="root">The project aggregate root.</param> public override void Save(Project root) { var project = new DB.Models.Project.Project { Id = root.Id.Id, Mandatory = root.Mandatory, Name = root.Name, Description = root.Description, ProjectOrderer = root.ProjectOrderer, RecievingOrganization = root.RecievingOrganization, StartDate = root.StartDate, EndDate = root.EndDate, DepartmentId = root.Department.Id, PpsClassificationId = root.Classification.Id, IsDeleted = root.IsDeleted, TeamMembers = root.TeamMembers == null ? null : root.TeamMembers.Select(x => new DB.Models.Project.ProjectRoleRelation { UserId = x.UserId.Id, ProjectRoleId = x.RoleId, ProjectId = root.Id.Id, EndDate = x.EndDate, StartDate = x.StartDate, FTE = x.FTE }), ManagerId = root.Manager.Id, OwnerId = root.Owner.Id }; if (root.IsNew) { _projectStorage.Add(project); } else { _projectStorage.Update(project); } }