public ActionResult Delete(CRUDHomeworkViewModel model)
        {

            HomeworkRepository repository = new HomeworkRepository();
            if (model.Id.ToString() != String.Empty)
            {
                repository.Delete(model.Id);
            }


            return RedirectToAction("Index");
        }
        public ActionResult Show(int id)
        {

            HomeworkRepository repository = new HomeworkRepository();

            Homework homework = repository.GetById(id);

            CRUDHomeworkViewModel model = new CRUDHomeworkViewModel();
            model.Title = homework.Title;
            model.Content = homework.Content;


            return View(model);
        }
        public ActionResult Edit(int? id)
        {

            HomeworkRepository repository = new HomeworkRepository();

            CRUDHomeworkViewModel model = new CRUDHomeworkViewModel();

            if (id.HasValue)
            {
                Homework homework = repository.GetById(id.Value);
                model.Id = homework.Id;
                model.Title = homework.Title;
                model.Content = homework.Content;
                homework.StudentId = user.Id;

            }

            return View(model);
        }
        public ActionResult Create(CRUDHomeworkViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            Homework homework = new Homework();
            // events.Id = model.Id;
            homework.Title = model.Title;
            homework.Content = model.Content;
            homework.StudentId = user.Id;
      


            var repository = new HomeworkRepository();
            repository.Insert(homework);

            return RedirectToAction("Index");
        }
        public ActionResult Edit(CRUDHomeworkViewModel model)
        {

            if (!ModelState.IsValid)
            {
                return View(model);
            }

            HomeworkRepository repository = new HomeworkRepository();

            Homework homework = new Homework();
            homework.Id = model.Id;


            homework.Title = model.Title;
            homework.Content = model.Content;
            homework.StudentId = user.Id;

            repository.Save(homework);

            return RedirectToAction("Index");
        }