public Project CreateProject(ProjectModel projectmodel) { //cast to dbo var project = CastToDbo(projectmodel); var _projectTechnologies = project.ProjectTechnologies; var _projectImagesUrls = project.ProjectImages; project.ProjectTechnologies = null; project.ProjectImages = null; var savedProject = _projectRepository.Create(project); if (_projectTechnologies != null) { foreach (var tech in _projectTechnologies) { tech.ProjectId = savedProject.ProjectId; _projectTechnologyRepository.Create(tech); } } if (_projectImagesUrls != null) { foreach (var image in _projectImagesUrls) { image.ProjectId = savedProject.ProjectId; _projectImageRepository.Create(image); } } return(_projectRepository.GetById(savedProject.ProjectId)); }
public ProjectTechnology AddTech(ProjectTechnology tech, int projectId) { tech.ProjectId = projectId; return(_projectTechnologyRepository.Create(tech)); }