public void OptionsRepositoriesUpdate_WidthChange_Success() { string optionName = "Option 1"; optionsRepository.Create(new NamedOption(optionName)); optionsRepository.Update(optionName, width: 20); Assert.AreEqual(20, optionsRepository.Get(optionName).Width); }
public async Task <IActionResult> Edit(HomeEditViewModel data) { if (ModelState.IsValid) { await questionsRepository.Update(new Questions { CorrectOption = data.Question.CorrectOption, QuestionId = data.Question.QuestionId, QuestionText = data.Question.QuestionText }); List <Options> optionsToUpdate = new List <Options> { new Options { OptionsId = data.Option1.OptionsId, OptionText = data.Option1.OptionText, QuestionId = data.Option1.QuestionId }, new Options { OptionsId = data.Option2.OptionsId, OptionText = data.Option2.OptionText, QuestionId = data.Option2.QuestionId }, new Options { OptionsId = data.Option3.OptionsId, OptionText = data.Option3.OptionText, QuestionId = data.Option3.QuestionId }, new Options { OptionsId = data.Option4.OptionsId, OptionText = data.Option4.OptionText, QuestionId = data.Option4.QuestionId } }; optionsRepository.Update(optionsToUpdate); return(RedirectToAction("Index")); } var optionsList = optionsRepository.GetByQuestionId(data.Question.QuestionId); data.Options = new List <Option> { new Option { Id = 1, OptionText = optionsList[0].OptionText }, new Option { Id = 2, OptionText = optionsList[1].OptionText }, new Option { Id = 3, OptionText = optionsList[2].OptionText }, new Option { Id = 4, OptionText = optionsList[3].OptionText } }; return(View(data)); }
public Option Update(int id) { var optionDb = _optionsRepository.GetbyId(id); if (optionDb == null) { throw new BusinessException("Opção não encontrada!"); } var optionOld = new Option(optionDb); optionDb.Count = CalculateVote(optionDb); return(_optionsRepository.Update(optionDb, optionOld)); }