public void GetAllCoursesTest() { var theme = new Theme("Test"); var result = _themeService.AddTheme(theme); theme = _themeService.GetThemeByName("Test"); var teacher = new User("*****@*****.**", "", new List <Course>()); _userService.AddTeacher(teacher, "Password_22"); teacher = _userService.GetTeacherByEmail("*****@*****.**"); var expected = new Course(0, theme, "aCourse", new DateTime(2020, 4, 14), new DateTime(2020, 4, 18), teacher); _courseService.AddCourse(expected); var res = _courseService.GetAllCourses().OrderBy(x => x.Name).ToList()[0]; Assert.AreEqual(expected.Name, res.Name); Assert.AreEqual(expected.Start, res.Start); Assert.AreEqual(expected.End, res.End); Assert.AreEqual(expected.Theme.Name, res.Theme.Name); Assert.AreEqual(expected.Teacher.Name, res.Teacher.Name); _courseService.DeleteCourse(res.CourseId); _themeService.DeleteTheme(theme.ThemeId); _userService.DeleteUser(teacher.Email); }
public void AddThemeTest() { var expected = new Theme("Test"); var result = _themeService.AddTheme(expected); Assert.AreEqual(expected.Name, result.Name); _themeService.DeleteTheme(result.ThemeId); }
public ActionResult Delete(Guid id, ThemeModel theme) { if (id == theme.Id) { try { service.DeleteTheme(theme); return(RedirectToAction("Index")); } catch (UpdateException) { theme = service.GetTheme(id); ViewData.Add(new KeyValuePair <string, object>(ViewRes.Theme.Erro + ':', ViewRes.Theme.UpdateException)); } catch (Exception e) { theme = service.GetTheme(id); ModelState.AddModelError("", e.Message); ViewData.Add(new KeyValuePair <string, object>(ViewRes.Theme.Erro + ':', ViewRes.Theme.UpdateException)); } } return(View(theme)); }
public async Task <IActionResult> DeleteTheme(PreviewThemeViewModel deletedTheme) { await themeService.DeleteTheme(deletedTheme); return(this.RedirectToAction("PreviewThemes", "Themes")); }
public ActionResult Delete(int themeId) { _themeService.DeleteTheme(themeId); return(RedirectToAction("List")); }
public async Task <IActionResult> DeleteTheme(long id) { await _themeService.DeleteTheme(id, _protector.Unprotect(Request.Cookies["accessToken"])); return(RedirectToAction("AllThemes", "Themes")); }
public async Task <ActionResult> DeleteTheme([Required] Guid themeId) { return(await _themeService .DeleteTheme(themeId) .HandleFailuresOrNoContent()); }
public ActionResult DeleteTheme(int id) { ThemeService.DeleteTheme(id); return(RedirectToAction("Index")); }
public async Task <ActionResult <bool> > DeleteTheme(long id) { return(Ok(await _themeService.DeleteTheme(id))); }