Exemplo n.º 1
0
        public ProductTryingOnControl()
        {
            InitializeComponent();

            viewModel        = new ClothingViewModel();
            this.DataContext = viewModel;
        }
Exemplo n.º 2
0
        public ActionResult ClothingView()
        {
            ClothingViewModel _ViewModelClothing = new ClothingViewModel();

            _ViewModelClothing.ClothingList = _mapper.ClothingMap(_ClothingDataAccess.GetAllClothing());
            return(View(_ViewModelClothing));
        }
Exemplo n.º 3
0
        public IActionResult Create([FromBody] ClothingViewModel clothing)
        {
            if (clothing == null)
            {
                return(BadRequest());
            }

            var id = _clothingService.Add(clothing);

            return(Created($"api/Clothing/{id}", id));  //HTTP201 Resource created
        }
Exemplo n.º 4
0
        public ActionResult MenClothing(string id)
        {
            Items                 db           = new Items();
            ClothingViewModel     ViewModel    = new ClothingViewModel();
            List <string>         brands       = db.ItemsUnites.Select(x => x.Brand).Distinct().ToList();
            List <SelectListItem> listOfBrands = new List <SelectListItem>();

            foreach (var item in brands)
            {
                SelectListItem selectItem = new SelectListItem
                {
                    Text  = item,
                    Value = item
                };
                listOfBrands.Add(selectItem);
            }
            List <string>         colors       = db.ItemsUnites.Select(x => x.Color).Distinct().ToList();
            List <SelectListItem> listOfColors = new List <SelectListItem>();

            foreach (var item in colors)
            {
                SelectListItem selectItem = new SelectListItem
                {
                    Text  = item,
                    Value = item
                };
                listOfColors.Add(selectItem);
            }
            List <SelectListItem> listOfSort = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Recommended", Value = "Recommended", Selected = true
                },
                new SelectListItem {
                    Text = "High to Low", Value = "High"
                },
                new SelectListItem {
                    Text = "Low to High", Value = "Low"
                }
            };

            List <Item> clothes = new List <Item>();

            clothes = db.ItemsUnites.ToList();


            ViewModel.ItemsModel = clothes;
            ViewModel.BrandItems = listOfBrands;
            ViewModel.SortItems  = listOfSort;
            ViewModel.ColorItems = listOfColors;
            return(View(ViewModel));
        }
        public IActionResult Clothing(string sortOrder, string movieGenre, string searchString, int pageIndex = 1)
        {
            int pageSize = 3;
            int count;
            var products = _productService.GetProducts(sortOrder, movieGenre, searchString, pageIndex, pageSize, out count);
            var genres   = _productService.GetGenres();
            var indexvm  = new ClothingViewModel()
            {
                Products     = new PaginatedList <ProductDto>(products, count, pageIndex, pageSize),
                Genres       = new SelectList(genres),
                ProductGenre = movieGenre,
                SearchString = searchString
            };

            return(View(indexvm));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("ClothingId,Category,Cost,Material,Image")] ClothingViewModel clothing)
        {
            if (id != clothing.ClothingId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    byte[] image = null;
                    using (var binaryReader = new BinaryReader(clothing.Image.OpenReadStream()))
                    {
                        image = binaryReader.ReadBytes((int)clothing.Image.Length);
                    }

                    var updClothing = new Clothing()
                    {
                        Category = clothing.Category, Cost = clothing.Cost, Image = image, Material = clothing.Material, ClothingId = clothing.ClothingId
                    };

                    _context.Update(updClothing);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClothingExists(clothing.ClothingId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("index"));
            }
            return(View(clothing));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Create(ClothingViewModel clothing)
        {
            Clothing clothing1 = new Clothing {
                Category = clothing.Category, Cost = clothing.Cost, Material = clothing.Material
            };

            if (ModelState.IsValid)
            {
                byte[] image = null;
                using (var binaryReader = new BinaryReader(clothing.Image.OpenReadStream()))
                {
                    image = binaryReader.ReadBytes((int)clothing.Image.Length);
                }
                clothing1.Image = image;

                _context.Clothes.Add(clothing1);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clothing));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var clothing = await _context.Clothes.FindAsync(id);

            if (clothing == null)
            {
                return(NotFound());
            }

            var clothingViewModel = new ClothingViewModel();

            clothingViewModel.Category   = clothing.Category;
            clothingViewModel.Cost       = clothing.Cost;
            clothingViewModel.Material   = clothing.Material;
            clothingViewModel.ClothingId = clothing.ClothingId;

            return(View(clothingViewModel));
        }
        public IActionResult AddClothes(ClothingViewModel clothingModel)
        {
            Clothing clothing = new Clothing();

            clothing.ClothingName = clothingModel.ClothingName;
            clothing.Material     = clothingModel.Material;
            clothing.Price        = clothingModel.Price;
            clothing.Color        = clothingModel.Color;

            if (!dbContext.Category.Any(c => c.CategoryName == clothingModel.Category))
            {
                Category category = new Category();
                category.CategoryName = clothingModel.Category;
                dbContext.Category.Add(category);
                dbContext.SaveChanges();
            }

            clothing.Category = dbContext.Category.Where(c => c.CategoryName == clothingModel.Category).FirstOrDefault();
            dbContext.Clothing.Add(clothing);

            dbContext.SaveChanges();

            return(RedirectToAction("Shop"));
        }
 public ClothingWindow()
 {
     InitializeComponent();
     // Note: no need to set the DataContext for the ComboBox.
     DataContext = new ClothingViewModel();
 }
Exemplo n.º 11
0
        public ActionResult MenClothing(ClothingViewModel model)
        {
            Items db = new Items();
            //filter brands
            List <string>         brands       = db.ItemsUnites.Select(x => x.Brand).Distinct().ToList();
            List <SelectListItem> listOfBrands = new List <SelectListItem>();

            foreach (var item in brands)
            {
                SelectListItem selectItem = new SelectListItem
                {
                    Text  = item,
                    Value = item
                };
                listOfBrands.Add(selectItem);
            }
            //filter colors
            List <string>         colors       = db.ItemsUnites.Select(x => x.Color).Distinct().ToList();
            List <SelectListItem> listOfColors = new List <SelectListItem>();

            foreach (var item in colors)
            {
                SelectListItem selectItem = new SelectListItem
                {
                    Text  = item,
                    Value = item
                };
                listOfColors.Add(selectItem);
            }
            //sort by list
            List <SelectListItem> listOfSort = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Recommended", Value = "Recommended", Selected = true
                },
                new SelectListItem {
                    Text = "High to Low", Value = "High"
                },
                new SelectListItem {
                    Text = "Low to High", Value = "Low"
                }
            };

            //items for sale
            List <Item> clothes = new List <Item>();


            if (model.Colors != null)
            {
                foreach (var item in model.Colors)
                {
                    List <Item> newList = db.ItemsUnites.Where(x => x.Color == item).ToList();
                    clothes.AddRange(newList);
                }
            }
            if (model.Brands != null)
            {
                foreach (var item in model.Brands)
                {
                    List <Item> newList = db.ItemsUnites.Where(x => x.Brand == item).ToList();
                    clothes.AddRange(newList);
                }
            }
            if (model.Brands == null && model.Colors == null)
            {
                clothes = db.ItemsUnites.ToList();
            }
            clothes = clothes.Distinct().ToList();

            if (model.Sorts == "High")
            {
                clothes = clothes.OrderByDescending(x => x.Price).ToList();
            }
            if (model.Sorts == "Low")
            {
                clothes = clothes.OrderBy(x => x.Price).ToList();
            }
            model.ItemsModel = clothes;
            model.SortItems  = listOfSort;
            model.BrandItems = listOfBrands;
            model.ColorItems = listOfColors;
            return(View(model));
        }
        public IActionResult AddClothes()
        {
            ClothingViewModel clothingModel = new ClothingViewModel();

            return(View(clothingModel));
        }