public JsonResult AddQuestionToContest([DataSourceRequest]DataSourceRequest request, ViewModelType model, int id)
        {
            var contest = this.Data.Contests.All().FirstOrDefault(c => c.Id == id);
            var question = model.GetEntityModel();

            contest.Questions.Add(question);
            this.Data.SaveChanges();

            this.UpdateAuditInfoValues(model, question);
            model.QuestionId = this.Data.Context.Entry(question).Property(pr => pr.Id).CurrentValue;
            model.ContestId = contest.Id;

            return this.Json(new[] { model }.ToDataSourceResult(request));
        }
예제 #2
0
 public JsonResult DeleteQuestionFromContest([DataSourceRequest] DataSourceRequest request, ViewModelType model)
 {
     this.Data.ContestQuestions.Delete(model.QuestionId.Value);
     this.Data.SaveChanges();
     return(this.GridOperation(request, model));
 }
예제 #3
0
        public JsonResult UpdateQuestionInContest([DataSourceRequest] DataSourceRequest request, ViewModelType model)
        {
            var entity = this.GetById(model.QuestionId) as DatabaseModelType;

            this.BaseUpdate(model.GetEntityModel(entity));
            this.UpdateAuditInfoValues(model, entity);
            return(this.GridOperation(request, model));
        }
예제 #4
0
        public JsonResult AddQuestionToContest([DataSourceRequest] DataSourceRequest request, ViewModelType model, int id)
        {
            var contest  = this.Data.Contests.All().FirstOrDefault(c => c.Id == id);
            var question = model.GetEntityModel();

            contest.Questions.Add(question);
            this.Data.SaveChanges();

            this.UpdateAuditInfoValues(model, question);
            model.QuestionId = this.Data.Context.Entry(question).Property(pr => pr.Id).CurrentValue;
            model.ContestId  = contest.Id;

            return(this.Json(new[] { model }.ToDataSourceResult(request)));
        }
 public JsonResult DeleteQuestionFromContest([DataSourceRequest]DataSourceRequest request, ViewModelType model)
 {
     this.Data.ContestQuestions.Delete(model.QuestionId.Value);
     this.Data.SaveChanges();
     return this.GridOperation(request, model);
 }
 public JsonResult UpdateQuestionInContest([DataSourceRequest]DataSourceRequest request, ViewModelType model)
 {
     var entity = this.GetById(model.QuestionId) as DatabaseModelType;
     this.BaseUpdate(model.GetEntityModel(entity));
     this.UpdateAuditInfoValues(model, entity);
     return this.GridOperation(request, model);
 }