/* * make for razer page */ public async Task <GetCategoryByIdOutput> GetCategoryById(int id) { var categories = await CategoryRepoditory.GetAll(); var mycategory = categories.FirstOrDefault(c => c.Id == id); if (mycategory == null) { throw new KeyNotFoundException("Not Found any category with this category"); } var result = new GetCategoryByIdOutput(); result.Image = mycategory.Image; result.Name = mycategory.Name; result.Places = TuristPlaceCategory.GetQuery().Include(tc => tc.Categories) .Include(tc => tc.TuristPlaces) .ThenInclude(p => p.Rates) .Where(tc => tc.Categories.Id == id) .Select(tc => tc.TuristPlaces) .Select(p => new Place() { AverageRates = p.Rates.Average(x => x.UserRate), CommentsNumber = TuristplaceRepository.GetQuery().Include(p => p.Comments).Where(c => c.Id == p.Id).Select(p => p.Comments.Count).FirstOrDefault(), Name = p.Name, Image = p.Image, Description = p.Description, Visit = p.Visit, Id = p.Id }) .ToList(); return(result); }
public async Task <IActionResult> OnGet(int id) { try { Category = await categoryServise.GetCategoryById(id); await categoryServise.DeleteById(id); State = true; return(Page()); } catch (Exception e) { State = false; ViewData["Error"] = e.Message; return(Page()); } }
public async Task OnGet(int id, string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); Category = await categoryServise.GetCategoryById(id); }