public Boolean insertProject(ProjectsDTO project) { //TODO Automap entities for code reduction var entity = new Projects(); entity.author = project.author; entity.bpm = Convert.ToString(project.bpm); entity.sampleRate = project.sampleRate; entity.name = project.name; entity.timestamp = DateTime.UtcNow.ToUniversalTime(); _context.Projects.Add(entity); var result = Save(); if (result == true) { project.stepSequencer.ForEach(ss => { ss.projID = _context.Projects.Last().id; ss.user = _context.Projects.Last().author; }); project.padPerformer.ForEach(ss => { ss.projID = _context.Projects.Last().id; ss.user = _context.Projects.Last().author; }); project.stepSequencer.ToList().ForEach(ss => _context.StepSequencer.Add(ss)); project.padPerformer.ToList().ForEach(ss => _context.Samples.Add(ss)); } return(Save()); }
public RespuestaWebAPI <ProjectsDTO> insertProject(ProjectsDTO projectDTO) { UnitOfWork unitOfWork = new UnitOfWork(); ProjectsRepository projectRepository = new ProjectsRepository(unitOfWork); RespuestaWebAPI <ProjectsDTO> respuestaWebApi = new RespuestaWebAPI <ProjectsDTO>(); try { Projects project = new Projects() { ProjectName = projectDTO.ProjectName, ShippingAddress = projectDTO.Address }; projectRepository.insertProject(project); unitOfWork.Save(); } catch (Exception exception) { respuestaWebApi.RegistrarExcepcion(GetType(), System.Reflection.MethodBase.GetCurrentMethod().Name, exception); } return(respuestaWebApi); }
public ProjectModel(ProjectsDTO projectDto) { ProjectId = projectDto.ProjectId; UserId = projectDto.UserId; ProjectName = projectDto.ProjectName; ProjectDescription = projectDto.ProjectDescription; }
public ActionResult <ProjectsDTO> Put([FromBody] ProjectsDTO projects) { var value = _mapper.Map <Projects>(projects); var project = _projectsService.Atualizar(value); if (project != null) { var retorno = _mapper.Map <ProjectsDTO>(project); return(Ok(project)); } else { return(NoContent()); } }
public void TestProjectContainer_Add_Project() { // Arrange ProjectsContext pContext = new ProjectsContext(); IEnumerable <ProjectsDTO> projects = new List <ProjectsDTO>(); ProjectsDTO project = new ProjectsDTO() { UserId = 1, ProjectName = "Project from Test in TestProjectsContext", ProjectDescription = "Test Description from Test in TestProjectsContext" }; // Act pContext.AddProject(project); projects = pContext.GetAllProjects(); var lastProject = projects.Last(); // Assert Assert.AreEqual(lastProject.ProjectName, "Project from Test in TestProjectsContext"); }
public ProjectsDTO getProject(int projID) { ProjectsDTO projects = new ProjectsDTO(); Projects prv = _context.Projects.Where(d => d.id == projID).SingleOrDefault(); var entity = new Projects(); projects.id = projID; projects.author = prv.author; projects.bpm = prv.bpm; projects.sampleRate = prv.sampleRate; projects.name = prv.name; projects.timestamp = DateTime.UtcNow.ToUniversalTime(); //Must be instantiated projects.padPerformer = new List <Samples>(); projects.padPerformer.AddRange(_context.Samples.Where(smp => smp.projID == projID).ToList()); projects.stepSequencer = new List <StepSequencer>(); projects.stepSequencer.AddRange(_context.StepSequencer.Where(smp => smp.projID == 37).ToList()); return(projects); }
public RespuestaWebAPI <ProjectsDTO> insertProject(ProjectsDTO project) { ProjectsService projectsService = new ProjectsService(); return(projectsService.insertProject(project)); }
public void Put([FromBody] ProjectsDTO value) { _projectRepository.updateProject(value); }
public void Post([FromBody] ProjectsDTO value) { _projectRepository.insertProject(value); }