public ActionResult Supprimer(int id) { ThemeServiceAPI rsa = new ThemeServiceAPI(); ThemeDetails r = new ThemeDetails(rsa.Donner(id)); return(View(r)); }
public async Task <int> ThemeDetailsAddOrUpdate(ThemeDetails newThemeDetails) { string proc = SpName.ThemeDetailsInsert; if (newThemeDetails.Id.HasValue) { proc = SpName.ThemeDetailsUpdate; } try { var result = await connection.QueryAsync <decimal>( proc, new { newThemeDetails.ProgramDetailId, newThemeDetails.Topic }, dbTransaction, commandType : CommandType.StoredProcedure ); return(decimal.ToInt32(result.FirstOrDefault())); } catch (SqlException ex) { Console.WriteLine(ex.Message); throw ex; } }
public static LessonTopicOutputModel ToOutputModel(ThemeDetails lessonTopic) { return(new LessonTopicOutputModel { Id = (int)lessonTopic.Id, Name = lessonTopic.Topic }); }
public static TopicToTeachOutputModel ToOutputModel(ThemeDetails topic) { return(new TopicToTeachOutputModel { ProgramDetailId = (int)topic.ProgramDetailId, Topic = topic.Topic }); }
public ActionResult Details(int id) { ThemeServiceAPI rsa = new ThemeServiceAPI(); Theme r = rsa.Donner(id); ThemeDetails rd = new ThemeDetails(r); return(View(rd)); }
private async void TestEntityDelete(ThemeDetails ThemeDetailsToDelete) { List <ThemeDetails> actualThemes = await courseStorage.ThemeDetailsGetAll(); await courseStorage.ThemeDetailsDeleteById((int)ThemeDetailsToDelete.Id); List <ThemeDetails> actualThemesAfterDelete = await courseStorage.ThemeDetailsGetAll(); Assert.AreEqual(actualThemes.Count - 1, actualThemesAfterDelete.Count); }
public static Theme VersTheme(this ThemeDetails e) { if (e == null) { return(null); } return(new Theme { id = e.id, actif = e.actif, description = e.description, titre = e.titre }); }
public ActionResult Supprimer(int id, ThemeDetails r) { if (ModelState.IsValid) { ThemeServiceAPI rsa = new ThemeServiceAPI(); bool b = rsa.Supprimer(id); if (b) { return(RedirectToAction("Index")); } } return(View(r)); }
private async void TestSelects() { List <ThemeDetails> actualThemes = await courseStorage.ThemeDetailsGetAll(); for (int i = 0; i < themeDetailsList.Count; i++) { ThemeDetails theme34 = themeDetailsList[i]; Assert.Contains(theme34, actualThemes); } ThemeDetails theme = await courseStorage.ThemeDetailsGetById((int)themeDetailsList[0].Id); Assert.AreEqual(themeDetailsList[0], theme); }
public void Should_have_validation_error_when_folder_is_empty() { var command = new ThemeDetails { Id = Guid.NewGuid(), Name = "Name", Description = "Description", Folder = string.Empty }; var themeRulesMock = new Mock <IThemeRules>(); var validator = new ThemeDetailsValidator <ThemeDetails>(themeRulesMock.Object); validator.ShouldHaveValidationErrorFor(x => x.Folder, command); }
private async void TestUpdate() { themeDetailsList[0].ProgramDetailId = 3; themeDetailsList[0].Topic = "Kjgeir"; await courseStorage.ThemeDetailsAddOrUpdate(themeDetailsList[0]); ThemeDetails theme1 = await courseStorage.ThemeDetailsGetById((int)themeDetailsList[0].Id); Assert.AreEqual(themeDetailsList[0], theme1); ThemeDetails theme2 = await courseStorage.ThemeDetailsGetById((int)themeDetailsList[3].Id); Assert.AreEqual(themeDetailsList[3], theme2); }
public async Task <ActionResult <int> > UpdateThemeDetails([FromBody] ThemeDetails themeDetails) { if (themeDetails == null) { return(BadRequest("Model is null")); } var result = await courseStorage.ThemeDetailsAddOrUpdate(themeDetails); if (result.Equals(null)) { return(BadRequest("Failed")); } return(Ok(result)); }
public void Should_have_validation_error_when_theme_name_is_not_unique() { var command = new ThemeDetails { Id = Guid.NewGuid(), Name = "Name", Description = "Description", Folder = "folder" }; var themeRulesMock = new Mock <IThemeRules>(); themeRulesMock.Setup(x => x.IsThemeNameUnique(command.Name, Guid.Empty)).Returns(false); var validator = new ThemeDetailsValidator <ThemeDetails>(themeRulesMock.Object); validator.ShouldHaveValidationErrorFor(x => x.Name, command); }
public void Should_have_validation_error_when_folder_is_not_valid() { var command = new ThemeDetails { Id = Guid.NewGuid(), Name = "Name", Description = "Description", Folder = "a@b" }; var themeRulesMock = new Mock <IThemeRules>(); themeRulesMock.Setup(x => x.IsThemeFolderValid(command.Description)).Returns(false); var validator = new ThemeDetailsValidator <ThemeDetails>(themeRulesMock.Object); validator.ShouldHaveValidationErrorFor(x => x.Folder, command); }
public void Should_have_validation_error_when_description_is_too_long() { var description = ""; for (int i = 0; i < 251; i++) { description += i; } var command = new ThemeDetails { Id = Guid.NewGuid(), Name = "Name", Description = description, Folder = "folder" }; var themeRulesMock = new Mock <IThemeRules>(); var validator = new ThemeDetailsValidator <ThemeDetails>(themeRulesMock.Object); validator.ShouldHaveValidationErrorFor(x => x.Description, command); }