public IActionResult Post(ProjectDTO model) { Project item = new Project(); model.UpdateFromModel(item); item.LastEdit = DateTime.Now; if (_projectRepo.NameExists(item.OwnerId, item.Name)) { return(Conflict("A project with this name already exists for that owner")); } _projectRepo.Add(item); _projectRepo.SaveChanges(); ProjectDTO dto = new ProjectDTO { Id = item.Id, Name = item.Name, TeamId = item.TeamId, OwnerId = item.OwnerId, LastEdit = item.LastEdit, ContactPerson = item.ContactPerson }; return(CreatedAtAction(nameof(GetAll), dto)); }
public IActionResult Put(int id, ProjectDTO model) { Project item = _projectRepo.GetById(id); if (item == null) { return(NotFound()); } model.UpdateFromModel(item); item.LastEdit = DateTime.Now; _projectRepo.SaveChanges(); return(NoContent()); }