public IActionResult Index() { var manifest = new { description = "Symbro NuGet symbol server API", services = new { sourceserver = "sourceserver/{packageId}/{*path}", symbolserver = "symbolserver/{module}/{guid}/{*ignore}", upload = "upload", }, }; return new ObjectResult(manifest); }
public IActionResult Login(AuthUser authUser) { if (ModelState.IsValid) { if (authUser.Username == "admin" && authUser.Password == "admin") { var claims = new[] { new Claim("name", authUser.Username), new Claim(ClaimTypes.Role, "Admin") }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); HttpContext.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity)); return Redirect("~/Home/Index"); } else { ModelState.AddModelError("","Login failed. Please check Username and/or password"); } } return View(); }
public object GetAds(string id, string classRoomId) { var areArgumentsValid = !string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(classRoomId); if (!areArgumentsValid) return null; var selectedClassRoom = _classRoomRepo.GetClassRoomById(classRoomId); var canAccessClassRoom = selectedClassRoom != null && selectedClassRoom.Lessons != null; if (!canAccessClassRoom) return null; var selectedLesson = selectedClassRoom.Lessons.FirstOrDefault(it => it.id == id); if (selectedLesson == null) return null; var selectedLessonCatalog = _lessonCatalogRepo.GetLessonCatalogById(selectedLesson.LessonCatalogId); var canAccessLessonCatalog = selectedLessonCatalog != null && selectedLessonCatalog.Advertisments != null && selectedLessonCatalog.Advertisments.Any(); if (!canAccessLessonCatalog) return null; var adsUrls = selectedLessonCatalog.Advertisments ?? Enumerable.Empty<LessonCatalog.Ads>(); var result = new { owl = adsUrls.Select(it => new { item = $"<div class='item'><img src='{ it.ImageUrl }' /></div>" }) }; return result; }
public object GetAds(string id) { var selectedCourse = _repo.GetCourseCatalogById(id); if (selectedCourse == null) return null; var adsUrls = selectedCourse.Advertisements ?? Enumerable.Empty<string>(); var result = new { owl = adsUrls.Select(it => new { item = $"<div class='item'><img src='{ it }' /></div>" }) }; return result; }