public IHttpActionResult Update(int id, HomeworkRequestModel homework) { if (!this.ModelState.IsValid) { return BadRequest(this.ModelState); } var homeworkInDb = this.data.Homeworks .All() .FirstOrDefault(c => c.Id == id); homeworkInDb.FileUrl = homework.FileUrl; this.data.Homeworks.SaveChanges(); return Ok(homeworkInDb); }
public IHttpActionResult Create(HomeworkRequestModel homework) { if (!this.ModelState.IsValid) { return BadRequest(this.ModelState); } this.data .Homeworks .Add(new Homework { FileUrl = homework.FileUrl, // StudentIdentification = homework.StudentIdentification, // CourseId = homework.CourseId }); this.data.Homeworks.SaveChanges(); return Ok(homework); }