public static TeamWork GetValidTeamWork() { var teamWork = new TeamWork() { Name = "WebServices", Description = "Description", EndDate = new DateTime(2015, 2, 1), Category = Category.CSharp }; teamWork.Requests.Add(GetValidTeamWorkRequest()); return teamWork; }
public IHttpActionResult Create(TeamworkModel teamWork) { if (!this.ModelState.IsValid) { return BadRequest(this.ModelState); } var currentUserId = this.userIdProvider.GetUserId(); var newTeamwork = new TeamWork() { Name = teamWork.Name, Description = teamWork.Description, GitHubLink = teamWork.GitHubLink, EndDate = teamWork.EndDate, Category = (Category)Enum.Parse(typeof(Category), teamWork.Category) }; newTeamwork.Users.Add(this.data.Users.Find(currentUserId)); this.data.TeamWorks.Add(newTeamwork); this.data.SaveChanges(); teamWork.Id = newTeamwork.Id; return Ok(teamWork); }