public ActionResult AddCategory(int id) { try { cateogryViewModel.Categories = Clogic.GetAllCategories(); Session["ArticleId"] = id; return(View(cateogryViewModel)); } catch (SqlException sqlException) { return(View("Error", sqlException)); } catch (InvalidCastException invalidCastException) { return(View("Error", invalidCastException)); } }
public IActionResult CreateService() { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Login")); } ViewBag.Categories = _categoryLogic.GetAllCategories().Select(category => category.Name); return(View()); }
public void GetAllCategories() { //Arrange ICategoryLogic logic = LogicFactory.CreateCategoryMemoryLogic(); List <Category> AllCategories = logic.GetAllCategories(); //Act int expected = 5; int actual = AllCategories.Count; //Assert Assert.AreEqual(expected, actual); }
//Read in CRUD public ActionResult Index() { var allCategories = _categoryLogic.GetAllCategories(); var categories = new List <CategoryViewModel>(); foreach (var categorie in allCategories) { categories.Add(new CategoryViewModel { //dasdasdasdasdasd }); } return(View(categories)); }
public IActionResult Index() { if (User.IsInRole("1")) { return(RedirectToAction("Index", "Admin")); } ViewData["Categories"] = _categoryLogic.GetAllCategories().Select(category => category.Name).ToList(); var model = new HomeViewModel() { OfferedServices = new List <OfferedServiceViewModel>() }; IEnumerable <IOfferedService> offeredServices; if (!User.Identity.IsAuthenticated) { offeredServices = _offeredServiceLogic.GetAllOfferedServices().Where(offeredService => offeredService.Status == 0 && !offeredService.Name.Contains("TEST")); } else { var currentUser = _userLogic.GetUserByEmail(User.Identity.Name); if (!currentUser.FullName.Contains("TEST")) { offeredServices = _offeredServiceLogic.GetAllOfferedServices().Where(offeredService => offeredService.Status == 0 && offeredService.ProviderId != currentUser.Id && !offeredService.Name.Contains("TEST")); } else { offeredServices = _offeredServiceLogic.GetAllOfferedServices().Where(offeredService => offeredService.Status == 0 && offeredService.ProviderId != currentUser.Id && offeredService.Name.Contains("TEST")); } } foreach (var offeredService in offeredServices.OrderByDescending(offeredService => offeredService.DateOfPost)) { var provider = new UserViewModel(_userLogic.GetUserById(offeredService.ProviderId)); var images = _imageLogic.GetImagesByOfferedServiceId(offeredService.Id) .Select(image => image.ToString()).ToList(); model.OfferedServices.Add(new OfferedServiceViewModel(offeredService, provider, images)); } return(View(model)); }
public IActionResult EditOfferedService(int offeredServiceId) { var offeredService = _offeredServiceLogic.GetOfferedServiceById(offeredServiceId); ViewBag.Categories = _categoryLogic.GetAllCategories().Select(category => category.Name); var model = new EditOfferedServiceViewModel() { Id = offeredServiceId, Name = offeredService.Name, Category = offeredService.Category, Price = offeredService.Price, Description = offeredService.Description, DeliveryTimeDays = offeredService.DeliveryTimeDays, DeliveryTimeHours = offeredService.DeliveryTimeHours, Images = _imageLogic.GetImagesByOfferedServiceId(offeredServiceId).Select(image => image.ToString()) .ToList() }; return(View(model)); }
public JsonResult GetCategories() { var categories = _iCategoryLogic.GetAllCategories(); return(Json(categories, JsonRequestBehavior.AllowGet)); }