public ActionResult DeleteContestForLecturer(
            [DataSourceRequest] DataSourceRequest request,
            LecturerInContestShortViewModel model)
        {
            var lecturerInContest = this.Data.LecturersInContests
                                    .All()
                                    .FirstOrDefault(x => x.LecturerId == model.LecturerId && x.ContestId == model.ContestId);

            this.Data.LecturersInContests.Delete(lecturerInContest);
            this.Data.SaveChanges();

            return(this.Json(this.ModelState.ToDataSourceResult(request)));
        }
        public ActionResult AddContestToLecturer(
            [DataSourceRequest] DataSourceRequest request,
            string userId,
            LecturerInContestShortViewModel model)
        {
            model.LecturerId = userId;

            var isInContest = this.Data.LecturersInContests
                              .All()
                              .Any(x => x.LecturerId == model.LecturerId && x.ContestId == model.ContestId);

            if (isInContest)
            {
                this.ModelState.AddModelError("LecturerId", "Потребителят вече е лектор в това състезание.");
            }
            else
            {
                var lecturerInContest = new DatabaseModelType
                {
                    LecturerId = model.LecturerId,
                    ContestId  = model.ContestId
                };

                this.Data.LecturersInContests.Add(lecturerInContest);
                this.Data.SaveChanges();

                var contestName = this.Data.Contests
                                  .All()
                                  .Where(x => x.Id == model.ContestId)
                                  .Select(x => x.Name)
                                  .FirstOrDefault();

                model.ContestName = contestName;
            }

            return(this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)));
        }