public ActionResult Delete(CRUDClassworkViewModel model)
        {
            ClassworkRepository repository = new ClassworkRepository();

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


            return(RedirectToAction("Index"));
        }
        public ActionResult Show(int id)
        {
            ClassworkRepository repository = new ClassworkRepository();

            Classwork classwork = repository.GetById(id);

            CRUDClassworkViewModel model = new CRUDClassworkViewModel();

            model.Title   = classwork.Title;
            model.Content = classwork.Content;


            return(View(model));
        }
        public ActionResult Edit(int?id)
        {
            ClassworkRepository repository = new ClassworkRepository();

            CRUDClassworkViewModel model = new CRUDClassworkViewModel();

            if (id.HasValue)
            {
                Classwork classwork = repository.GetById(id.Value);
                model.Id        = classwork.Id;
                model.Title     = classwork.Title;
                model.Content   = classwork.Content;
                model.StudentId = user.Id;
            }

            return(View(model));
        }
        public ActionResult Edit(CRUDClassworkViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            ClassworkRepository repository = new ClassworkRepository();

            Classwork classwork = new Classwork();

            classwork.Id = model.Id;


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

            repository.Save(classwork);

            return(RedirectToAction("Index"));
        }
        public ActionResult Create(CRUDClassworkViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Classwork classwork = new Classwork();

            // events.Id = model.Id;
            classwork.Title     = model.Title;
            classwork.Content   = model.Content;
            classwork.StudentId = user.Id;



            var repository = new ClassworkRepository();

            repository.Insert(classwork);

            return(RedirectToAction("Index"));
        }