public bool AddShoes(ShoesAddViewModel shoesVM)
        {
            //Shoes shoes = _mapper.Map<Shoes>(shoesVM);
            Brand brand = _brandRepository.GetById(shoesVM.BrandId);

            if (brand != null)
            {
                Shoes shoes = new Shoes()
                {
                    Name        = shoesVM.Name,
                    Brand       = brand,
                    Color       = shoesVM.Color,
                    IsAvaiable  = true,
                    Description = shoesVM.Description,
                    Price       = shoesVM.Price,
                    Sex         = shoesVM.Sex
                };

                _shoesRepository.Add(shoes);

                foreach (var img in shoesVM.Images)
                {
                    _imageRepository.Add(new Image()
                    {
                        IsShoes     = true,
                        Url         = img,
                        Description = shoes.Name + "'s image",
                        OwnId       = shoes.Id
                    });
                }
                return(true);
            }
            return(false);
        }
        public IActionResult AddShoes(ShoesAddViewModel shoesAddViewModel)
        {
            bool result = _shoesService.AddShoes(shoesAddViewModel);

            if (result == true)
            {
                return(new JsonResult(result)
                {
                    StatusCode = StatusCodes.Status200OK
                });
            }

            return(new JsonResult(result)
            {
                StatusCode = StatusCodes.Status409Conflict
            });
        }
        public bool Update(ShoesAddViewModel shoesVM)
        {
            Brand brand = _brandRepository.GetById(shoesVM.BrandId);

            if (brand != null)
            {
                Shoes shoes = _shoesRepository.GetById(shoesVM.Id);
                if (shoes != null)
                {
                    shoes.Name        = shoesVM.Name;
                    shoes.Brand       = brand;
                    shoes.Color       = shoesVM.Color;
                    shoes.Description = shoesVM.Description;
                    shoes.Price       = shoesVM.Price;
                    shoes.Sex         = shoesVM.Sex;

                    _shoesRepository.Update(shoes);

                    List <Image> images = _imageRepository.GetAll().Where(i => i.IsShoes == true && i.OwnId == shoes.Id).ToList();
                    foreach (var i in images)
                    {
                        _imageRepository.Delete(i);
                    }

                    foreach (var img in shoesVM.Images)
                    {
                        _imageRepository.Add(new Image()
                        {
                            IsShoes     = true,
                            Url         = img,
                            Description = shoes.Name + "'s image",
                            OwnId       = shoes.Id
                        });
                    }
                    return(true);
                }
                return(false);
            }
            return(false);
        }