public IActionResult Index(int category_id) { CategoryPageViewModel model = new CategoryPageViewModel() { Categories = _categoryLogic.GetAll().Select(c => new CategoryViewModel { Id = c.CategoryId, Name = c.Name }).ToList(), Posts = _postLogic.GetAllPostsByCategory(category_id).Select(c => new PostViewModel { Title = c.Title, Content = c.Content, PostId = c.PostId, AuraAmount = c.Aura.Amount, PostDate = c.PostDate, UserName = c.User.Name, CategoryName = c.Category.Name }).ToList(), CategoryName = _categoryLogic.GetCategoryById(category_id).Name, }; return(View(model)); }
public IActionResult Index() { SubmitPageViewModel model = new SubmitPageViewModel() { Categories = _categoryLogic.GetAll().Select(c => new CategoryViewModel { Id = c.CategoryId, Name = c.Name }).ToList() }; return(View(model)); }
public IActionResult Register() { RegisterPageViewModel model = new RegisterPageViewModel() { Categories = _categoryLogic.GetAll().Select(c => new CategoryViewModel { Id = c.CategoryId, Name = c.Name }).ToList(), }; return(View(model)); }
public void GetAllNullTest() { List <Category> categories = new List <Category>(); var mockCategory = new Mock <IRepository <Category> >(MockBehavior.Strict); mockCategory.Setup(p => p.GetAll()).Returns(categories); var logic = new CategoryLogic(mockCategory.Object); var result = logic.GetAll(); mockCategory.VerifyAll(); Assert.IsTrue(result.SequenceEqual(categories)); }
public IActionResult Index() { ViewBag.Name = HttpContext.Session.GetString("Username"); HomePageViewModel model = new HomePageViewModel() { Categories = _categoryLogic.GetAll().Select(c => new CategoryViewModel { Id = c.CategoryId, Name = c.Name }).ToList(), Posts = _postLogic.GetAllPosts().Select(c => new PostViewModel { Title = c.Title, Content = c.Content, PostId = c.PostId, AuraAmount = c.Aura.Amount, PostDate = c.PostDate, UserName = c.User.Name, CategoryName = c.Category.Name }).ToList(), }; return(View(model)); }
public ApiModule() : base("/api") { #region /// Help Page /// Get["/help"] = x => View["help"]; #endregion #region /// Category /// #region /// /api/Categories/ /// Get["/categories"] = x => { var logic = new CategoryLogic(); var result = logic.GetAll(); return Response.AsJson(result); }; #endregion #region /// /api/Categories/1234 /// Get["/categories/{id:int}"] = x => { var logic = new CategoryLogic(); var result = logic.GetById((int)x.id); return Response.AsJson(result); }; #endregion #endregion #region /// Customer /// #region /// /api/Customers/ /// Get["/customers"] = x => { var logic = new CustomerLogic(); var result = logic.GetAll(); return Response.AsJson(result); }; #endregion #region /// /api/Customers/1234 /// Get["/customers/{id*}"] = x => { var logic = new CustomerLogic(); var result = logic.GetById((string)x.id); return Response.AsJson(result); }; #endregion #endregion #region /// Employee /// #region /// /api/employees /// Get["/employees"] = x => { var logic = new EmployeeLogic(); var result = logic.GetAll(); return Response.AsJson(result); }; #endregion #region /// /api/employees/1234 /// Get["/employees/{id:int}"] = x => { var logic = new EmployeeLogic(); var result = logic.GetById((int)x.id); return Response.AsJson(result); }; #endregion #endregion #region /// Order /// #region /// /api/Orders/ /// Get["/orders"] = x => { var logic = new OrderLogic(); var result = logic.GetAll(); return Response.AsJson(result); }; #endregion #region /// /api/Orders/1234 /// Get["/orders/{id:int}"] = x => { var logic = new OrderLogic(); var result = logic.GetById((int)x.id); return Response.AsJson(result); }; #endregion #endregion #region /// Product /// #region /// /api/Products/ /// Get["/products"] = x => { var logic = new ProductLogic(); var result = logic.GetAll(); return Response.AsJson(result); }; #endregion #region /// /api/Products/1234 /// Get["/products/{id:int}"] = x => { var logic = new ProductLogic(); var result = logic.GetById((int)x.id); return Response.AsJson(result); }; #endregion #endregion #region /// Region /// #region /// /api/Regions/ /// Get["/regions"] = x => { var logic = new RegionLogic(); var result = logic.GetAll(); return Response.AsJson(result); }; #endregion #region /// /api/Regions/1234 /// Get["/regions/{id:int}"] = x => { var logic = new RegionLogic(); var result = logic.GetById((int)x.id); return Response.AsJson(result); }; #endregion #endregion #region /// Shipper /// #region /// /api/Shippers/ /// Get["/shippers"] = x => { var logic = new ShipperLogic(); var result = logic.GetAll(); return Response.AsJson(result); }; #endregion #region /// /api/Shippers/1234 /// Get["/shippers/{id:int}"] = x => { var logic = new ShipperLogic(); var result = logic.GetById((int)x.id); return Response.AsJson(result); }; #endregion #endregion #region /// Supplier /// #region /// /api/Suppliers/ /// Get["/suppliers"] = x => { var logic = new SupplierLogic(); var result = logic.GetAll(); return Response.AsJson(result); }; #endregion #region /// /api/Suppliers/1234 /// Get["/suppliers/{id:int}"] = x => { var logic = new SupplierLogic(); var result = logic.GetById((int)x.id); return Response.AsJson(result); }; #endregion #endregion #region /// Territory /// #region /// /api/Territories/ /// Get["/territories"] = x => { var logic = new TerritoryLogic(); var result = logic.GetAll(); return Response.AsJson(result); }; #endregion #region /// /api/Territories/1234 /// Get["/territories/{id:string}"] = x => { var logic = new TerritoryLogic(); var result = logic.GetById((string)x.id); return Response.AsJson(result); }; #endregion #endregion }
public ApiModule() : base("/api") { #region /// Help Page /// Get["/help"] = x => View["help"]; #endregion #region /// Category /// #region /// /api/Categories/ /// Get["/categories"] = x => { var logic = new CategoryLogic(); var result = logic.GetAll(); return(Response.AsJson(result)); }; #endregion #region /// /api/Categories/1234 /// Get["/categories/{id:int}"] = x => { var logic = new CategoryLogic(); var result = logic.GetById((int)x.id); return(Response.AsJson(result)); }; #endregion #endregion #region /// Customer /// #region /// /api/Customers/ /// Get["/customers"] = x => { var logic = new CustomerLogic(); var result = logic.GetAll(); return(Response.AsJson(result)); }; #endregion #region /// /api/Customers/1234 /// Get["/customers/{id*}"] = x => { var logic = new CustomerLogic(); var result = logic.GetById((string)x.id); return(Response.AsJson(result)); }; #endregion #endregion #region /// Employee /// #region /// /api/employees /// Get["/employees"] = x => { var logic = new EmployeeLogic(); var result = logic.GetAll(); return(Response.AsJson(result)); }; #endregion #region /// /api/employees/1234 /// Get["/employees/{id:int}"] = x => { var logic = new EmployeeLogic(); var result = logic.GetById((int)x.id); return(Response.AsJson(result)); }; #endregion #endregion #region /// Order /// #region /// /api/Orders/ /// Get["/orders"] = x => { var logic = new OrderLogic(); var result = logic.GetAll(); return(Response.AsJson(result)); }; #endregion #region /// /api/Orders/1234 /// Get["/orders/{id:int}"] = x => { var logic = new OrderLogic(); var result = logic.GetById((int)x.id); return(Response.AsJson(result)); }; #endregion #endregion #region /// Product /// #region /// /api/Products/ /// Get["/products"] = x => { var logic = new ProductLogic(); var result = logic.GetAll(); return(Response.AsJson(result)); }; #endregion #region /// /api/Products/1234 /// Get["/products/{id:int}"] = x => { var logic = new ProductLogic(); var result = logic.GetById((int)x.id); return(Response.AsJson(result)); }; #endregion #endregion #region /// Region /// #region /// /api/Regions/ /// Get["/regions"] = x => { var logic = new RegionLogic(); var result = logic.GetAll(); return(Response.AsJson(result)); }; #endregion #region /// /api/Regions/1234 /// Get["/regions/{id:int}"] = x => { var logic = new RegionLogic(); var result = logic.GetById((int)x.id); return(Response.AsJson(result)); }; #endregion #endregion #region /// Shipper /// #region /// /api/Shippers/ /// Get["/shippers"] = x => { var logic = new ShipperLogic(); var result = logic.GetAll(); return(Response.AsJson(result)); }; #endregion #region /// /api/Shippers/1234 /// Get["/shippers/{id:int}"] = x => { var logic = new ShipperLogic(); var result = logic.GetById((int)x.id); return(Response.AsJson(result)); }; #endregion #endregion #region /// Supplier /// #region /// /api/Suppliers/ /// Get["/suppliers"] = x => { var logic = new SupplierLogic(); var result = logic.GetAll(); return(Response.AsJson(result)); }; #endregion #region /// /api/Suppliers/1234 /// Get["/suppliers/{id:int}"] = x => { var logic = new SupplierLogic(); var result = logic.GetById((int)x.id); return(Response.AsJson(result)); }; #endregion #endregion #region /// Territory /// #region /// /api/Territories/ /// Get["/territories"] = x => { var logic = new TerritoryLogic(); var result = logic.GetAll(); return(Response.AsJson(result)); }; #endregion #region /// /api/Territories/1234 /// Get["/territories/{id:string}"] = x => { var logic = new TerritoryLogic(); var result = logic.GetById((string)x.id); return(Response.AsJson(result)); }; #endregion #endregion }
public void GetAll_Expects_True() { var categories = _categoryLogic.GetAll(); Assert.AreEqual(3, categories.Count); }
public void GetAll() { List <CategoryDTO> categoryList = categoryLogic.GetAll(); Assert.AreEqual(categoryList.Count, 2); }