public IHttpActionResult Put(int id, HomeworkApiModel model)
        {
            if (!ModelState.IsValid)
            {
                return(this.BadRequest(ModelState));
            }

            var homeworkFromDb = this.Data.Homeworks
                                 .Find(id);

            homeworkFromDb.Content   = model.Content;
            homeworkFromDb.TimeSent  = model.TimeSent;
            homeworkFromDb.CourseId  = model.CourseId;
            homeworkFromDb.StudentId = model.StudentId;

            this.Data.SaveChanges();

            return(this.Ok());
        }
        public IHttpActionResult Post(HomeworkApiModel model)
        {
            if (!ModelState.IsValid)
            {
                return this.BadRequest(ModelState);
            }
            var homeworkForDb = new Homework()
            {
                Content = model.Content,
                TimeSent = model.TimeSent,
                CourseId = model.CourseId,
                StudentId = model.StudentId
            };

            this.Data.Homeworks.Add(homeworkForDb);
            this.Data.SaveChanges();

            return this.Ok(model);
        }
        public IHttpActionResult Post(HomeworkApiModel model)
        {
            if (!ModelState.IsValid)
            {
                return(this.BadRequest(ModelState));
            }
            var homeworkForDb = new Homework()
            {
                Content   = model.Content,
                TimeSent  = model.TimeSent,
                CourseId  = model.CourseId,
                StudentId = model.StudentId
            };

            this.Data.Homeworks.Add(homeworkForDb);
            this.Data.SaveChanges();

            return(this.Ok(model));
        }
        public IHttpActionResult Put(int id, HomeworkApiModel model)
        {
            if (!ModelState.IsValid)
            {
                return this.BadRequest(ModelState);
            }

            var homeworkFromDb = this.Data.Homeworks
                .Find(id);

            homeworkFromDb.Content = model.Content;
            homeworkFromDb.TimeSent = model.TimeSent;
            homeworkFromDb.CourseId = model.CourseId;
            homeworkFromDb.StudentId = model.StudentId;

            this.Data.SaveChanges();

            return this.Ok();
        }