public IHttpActionResult Update(int id, HomeworkModel homeworkModel)
        {
            if (!this.ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var existingHomework = this.data.Homeworks.Find(id);
            if (existingHomework == null)
            {
                return BadRequest("Homework with such id does not exist!");
            }

            if (homeworkModel.TimeSent != null)
            {
                existingHomework.TimeSent = homeworkModel.TimeSent;
            }   
            
            this.data.SaveChanges();

            homeworkModel.Id = id;
            return this.Ok(homeworkModel);
        }
        public IHttpActionResult Create(Homework homework)
        {
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var student = data.Students.Find(homework.StudentId);
            if (student == null)
            {
                return this.BadRequest("Student with such id does not exist!");
            }

            var courseId = homework.CourseId;
            var course = data.Courses.Find(courseId);
            if (course == null)
            {
                return this.BadRequest("Course with such id does not exist!");
            }

            this.data.Homeworks.Add(homework);
            this.data.SaveChanges();

            var hwModel = new HomeworkModel() {
                Id = homework.Id,
                TimeSent = homework.TimeSent,
                Course = homework.Course.Name,
                Student = homework.Student.FirstName + " " + homework.Student.LastName
            };

            return this.CreatedAtRoute("DefaultApi", new { id = homework.Id }, hwModel);    
        }