Exemplo n.º 1
0
 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));
     }
 }
Exemplo n.º 2
0
        public IActionResult CreateService()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Login"));
            }

            ViewBag.Categories = _categoryLogic.GetAllCategories().Select(category => category.Name);
            return(View());
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        //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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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));
        }