public ActionResult Edit(AuxTestPoolEntryModel editTestPoolEntry) { try { var type = editTestPoolEntry.Type; var value = editTestPoolEntry.Value; var entity = _modelLoader.Load(editTestPoolEntry.Id); switch (type) { case nameof(SaveTestPoolEntryModel.ScoringStrategy): switch (value) { case 0: entity.ScoringStrategy = ScoringStrategy.AllCorrectVariantsShouldBeSpecified; break; case 1: entity.ScoringStrategy = ScoringStrategy.AnyCorrectVariantCanBeSpecified; break; default: break; } break; case nameof(SaveTestPoolEntryModel.Score): entity.Score = value; break; default: throw new Exception("Присланное не соответствует формату данных!"); } var model = new SaveTestPoolEntryModel { Id = entity.Id, Score = entity.Score, ScoringStrategy = entity.ScoringStrategy, TestPool = entity.TestPool.Id, TestQuestion = entity.TestQuestion.Id, }; _modelSaver.CreateOrUpdate(model); return(Json(true)); } catch (GraphLabsDbUpdateException e) { return(Json(false)); } catch (EntityNotFoundException e) { return(Json(false)); } }
public ActionResult Create(SaveTestPoolEntryModel saveTestPoolEntry) { try { var testPoolEntryCreated = _modelSaver.CreateOrUpdate(saveTestPoolEntry); return(Json(testPoolEntryCreated.Id)); } catch (EntityNotFoundException e) { return(Json(false)); } catch (GraphLabsDbUpdateException e) { return(Json(false)); } }
public ActionResult Delete(SaveTestPoolEntryModel testPoolEntryIdStr) { try { var testPoolEntryId = testPoolEntryIdStr.Id; _modelRemover.Remove(testPoolEntryId); return(Json(true)); } catch (GraphLabsDbUpdateException e) { return(Json(false)); } catch (EntityNotFoundException e) { return(Json(false)); } }