public ActionResult Edit()
        {
            BrandRepository repo = new BrandRepository();

            BrandsViewModel model = new BrandsViewModel(repo.GetAll());

            return(View(model));
        }
        public BrandsView(BrandsViewModel _bvm)
        {
            InitializeComponent();

            BindingContext = _bvm;

            bvm = _bvm;
        }
Exemple #3
0
        public PartialViewResult GetBags(string producer, string material)
        {
            var producerList = getModelsByField(producer, "Producer", typeof(Bag));
            var materialList = getModelsByField(material, "Material", typeof(Bag));
            var bVM          = new BrandsViewModel();

            bVM.PreferedProducts = producerList.Intersect(materialList).ToList();
            return(PartialView("Products/_BagsList", bVM));
        }
Exemple #4
0
        public PartialViewResult GetTShirts(string producer, string size)
        {
            var producerList = getModelsByField(producer, "Producer", typeof(TShirt));
            var sizeList     = getModelsByField(size, "AvailiableSize", typeof(TShirt));
            var bVM          = new BrandsViewModel();

            bVM.PreferedProducts = producerList.Intersect(sizeList).ToList();
            return(PartialView("Products/_TShirtsList", bVM));
        }
Exemple #5
0
        public PartialViewResult GetBicycles(string producer, string wheelsize)
        {
            var producerList  = getModelsByField(producer, "Producer", typeof(Bicycle));
            var wheelSizeList = getModelsByField(wheelsize, "WheelsSize", typeof(Bicycle));
            var bVM           = new BrandsViewModel();

            bVM.PreferedProducts = producerList.Intersect(wheelSizeList).ToList();
            return(PartialView("Products/_BicyclesList", bVM));
        }
Exemple #6
0
        public ActionResult AllBrands()// <--method
        {
            ViewBag.Message = "All Brands";

            BrandsViewModel viewModel = new BrandsViewModel();//gives me acces to this class

            viewModel.AllBrands = mapper.Map(brandDAL.GetBrands());
            return(View(viewModel));
        }
        public ActionResult Create()
        {
            var viewModel = new BrandsViewModel
            {
                Heading = "Add a part"
            };

            return(View(viewModel));
        }
Exemple #8
0
        public PartialViewResult GetProducts(string producer, string gender)
        {
            var producerList = getModelsByField(producer, "Producer", typeof(Shoes));
            var genderList   = getModelsByField(gender, "Gender", typeof(Shoes));
            var bVM          = new BrandsViewModel();

            bVM.PreferedProducts = producerList.Intersect(genderList).ToList();
            return(PartialView("Products/_ProductsList", bVM));
        }
Exemple #9
0
    public ActionResult Index()
    {
        var brands = _repository.Get();
        var model  = new BrandsViewModel
        {
            Brands = Mapper.Map <IEnumerable <Brand>, IEnumerable <SelectListItem> >(brands)
        };

        return(View(model));
    }
        public IActionResult Index()
        {
            var brandsVM = new BrandsViewModel();

            foreach (var brand in ProductRepository.GetAll().GroupBy(x => x.Producer)
                     .Where(y => y.Any(z => z.isPrefered == true)))
            {
                brandsVM.BrandInfo.Add(Tuple.Create(brand.Key, brand.Count()));
            }
            brandsVM.PreferedProducts = ProductRepository.GetAll().Where(x => x.isPrefered == true).ToList();
            return(View(brandsVM));
        }
        public IActionResult Bicycles()
        {
            var models   = ProductRepository.GetByType(typeof(Bicycle));
            var brandsVM = new BrandsViewModel();

            foreach (var brand in models.GroupBy(x => x.Producer))
            {
                brandsVM.BrandInfo.Add(Tuple.Create(brand.Key, brand.Count()));
            }
            brandsVM.PreferedProducts = models.ToList();
            return(View(brandsVM));
        }
        public IActionResult Edit([FromForm] BrandsViewModel brandsViewModel)
        {
            var brand = brandService.Get(brandsViewModel.Id);

            if (brand == null)
            {
                return(RedirectToAction(nameof(Index)));
            }
            brand.Name = brandsViewModel.Name;
            brandService.Update(brand);

            return(RedirectToAction("Index"));
        }
        public ActionResult Update(BrandsViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Heading = "Update Brand";
                return(View("Create", viewModel));
            }
            var brand = _unitOfWork.Brands.GetBrandWithBrandId(viewModel.Id);

            brand.Modify(viewModel.BrandName, viewModel.ImageUrl);

            _unitOfWork.Complete();
            return(RedirectToAction("BrandList", "Brands"));
        }
        public ActionResult EditBrand(BrandsViewModel model)
        {
            BrandRepository repo  = new BrandRepository();
            Brand           brand = repo.GetByID(model.ID);

            if (brand == null)
            {
                brand = new Brand();
            }
            brand.Name            = model.Name;
            brand.CountryOfOrigin = model.CountryOfOrigin;
            repo.Save(brand);
            return(RedirectToAction("Edit"));
        }
        public ActionResult Edit(int id)
        {
            Brand brand = _unitOfWork.Brands.GetBrandWithBrandId(id);

            var viewModel = new BrandsViewModel
            {
                Heading   = "Edit Brand",
                BrandName = brand.BrandName,
                ImageUrl  = brand.LogoImgSrc,
                Id        = brand.Id
            };

            return(View("Create", viewModel));
        }
    public ActionResult Index()
    {
        var brands = _repository.Get().Select(b => new SelectListItem
        {
            Value = b.Id,
            Text  = b.Name
        });
        var model = new BrandsViewModel
        {
            Brands = brands
        };

        return(View(model));
    }
        public ActionResult Edit(BrandsViewModel brandsViewModel, HttpPostedFileBase files, string submit)
        {
            if (ModelState.IsValid)
            {
                if (brandsViewModel != null && submit == "Save")
                {
                    brandsViewModel.DateCreated  = brandsViewModel.DateCreated;
                    brandsViewModel.DateModified = DateTime.UtcNow;

                    if (files != null)
                    {
                        // Delete exiting file
                        // System.IO.File.Delete(Path.Combine(Server.MapPath("~/Images/Category/"), serviceViewModel.Image));
                        // Save new file
                        var fileName = Path.GetFileName(files.FileName);
                        var path     = Path.Combine(Server.MapPath("~/UploadFiles/Brands/"), fileName);
                        files.SaveAs(path);
                        brandsViewModel.Image = fileName;
                    }
                    var sliderImage = Mapper.Map <BrandsViewModel, Brand>(brandsViewModel);
                    _brandSliderService.Edit(sliderImage);
                    AddMessage(this, "", "Record has been modified Successfully", MessageType.Success);
                    return(RedirectToAction("Index", "BrandsSlider"));
                }
                if (brandsViewModel != null && submit == "SaveAndContinue")
                {
                    brandsViewModel.DateCreated  = brandsViewModel.DateCreated;
                    brandsViewModel.DateModified = DateTime.UtcNow;
                    if (files != null)
                    {
                        // Delete exiting file
                        // System.IO.File.Delete(Path.Combine(Server.MapPath("~/Images/Category/"), serviceViewModel.Image));
                        // Save new file
                        var fileName = Path.GetFileName(files.FileName);
                        var path     = Path.Combine(Server.MapPath("~/UploadFiles/Brands/"), fileName);
                        files.SaveAs(path);
                        brandsViewModel.Image = fileName;
                    }
                    var sliderImage = Mapper.Map <BrandsViewModel, Brand>(brandsViewModel);
                    _brandSliderService.Edit(sliderImage);

                    var id = sliderImage.Id;
                    AddMessage(this, "", "Record has been modified successfully", MessageType.Success);
                    return(RedirectToAction("Edit", new { id = id }));
                }
            }
            return(View(brandsViewModel));
        }
        public IActionResult Create([FromForm] BrandsViewModel model)
        {
            if (ModelState.IsValid)
            {
                return(View(model));
            }
            var brandDto = new BrandDto()
            {
                BrandId = model.Id,
                Name    = model.Name
            };

            brandService.Add(brandDto);

            return(RedirectToAction("Index"));
        }
        public IActionResult Edit(int id)
        {
            var brand = brandService.Get(id);

            if (brand == null)
            {
                return(RedirectToAction(nameof(Index)));
            }

            var brandViewModel = new BrandsViewModel
            {
                Id   = brand.BrandId,
                Name = brand.Name
            };

            return(View(brandViewModel));
        }
        public IActionResult Details(int id)
        {
            var brand = brandService.Get(id);

            if (brand == null)
            {
                return(View("NotFound"));
            }

            var model = new BrandsViewModel
            {
                Id   = brand.BrandId,
                Name = brand.Name
            };

            return(View(model));
        }
Exemple #21
0
        public ActionResult Create(BrandsViewModel _viewModel, HttpPostedFileBase image)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create"));
            }

            ImageUpload(image);
            var _brandModel = new Brand
            {
                BrandName  = _viewModel.BrandName,
                LogoImgSrc = _imageurl
            };

            _unitOfWork.Brands.AddBrand(_brandModel);
            _unitOfWork.Complete();
            return(RedirectToAction("BrandList", "Brands"));
        }
        public ActionResult Create(BrandsViewModel brandsViewModel, IEnumerable <HttpPostedFileBase> files, string submit)
        {
            if (ModelState.IsValid)
            {
                if (brandsViewModel != null && submit == "Save")
                {
                    brandsViewModel.DateCreated  = DateTime.UtcNow;
                    brandsViewModel.DateModified = DateTime.UtcNow;
                    foreach (var file in files)
                    {
                        //Some browsers send file names with a full path. You only care about the file name.
                        var fileName        = Path.GetFileName(file.FileName);
                        var destinationPath = Path.Combine(Server.MapPath("~/UploadFiles/Brands/"), fileName);
                        brandsViewModel.Image = fileName;
                        file.SaveAs(destinationPath);
                    }
                    var sliderImage = Mapper.Map <BrandsViewModel, Brand>(brandsViewModel);

                    _brandSliderService.Add(sliderImage);
                    AddMessage(this, "", "Record has Added Successfully", MessageType.Success);
                    return(RedirectToAction("Index", "BrandsSlider"));
                }
                if (brandsViewModel != null && submit == "SaveAndContinue")
                {
                    brandsViewModel.DateCreated  = DateTime.UtcNow;
                    brandsViewModel.DateModified = DateTime.UtcNow;
                    foreach (var file in files)
                    {
                        //Some browsers send file names with a full path. You only care about the file name.
                        var fileName        = Path.GetFileName(file.FileName);
                        var destinationPath = Path.Combine(Server.MapPath("~/UploadFiles/Brands/"), fileName);
                        brandsViewModel.Image = fileName;
                        file.SaveAs(destinationPath);
                    }
                    var sliderImage = Mapper.Map <BrandsViewModel, Brand>(brandsViewModel);

                    _brandSliderService.Add(sliderImage);
                    AddMessage(this, "", "Record has Added Successfully", MessageType.Success);
                    ModelState.Clear();
                    return(View());
                }
            }
            return(View(brandsViewModel));
        }
        public ActionResult Create(BrandsViewModel _viewModel)
        {
            if (!ModelState.IsValid)
            {
                _viewModel.Heading = "Add a part";
                return(View("Create", _viewModel));
            }

            ImageUpload(_viewModel.BrandLogo, UPLOAD_DIRECTORY);
            var _brandModel = new Brand
            {
                BrandName  = _viewModel.BrandName,
                LogoImgSrc = Path.Combine(UPLOAD_DIRECTORY, _viewModel.BrandLogo.FileName)
            };

            _unitOfWork.Brands.AddBrand(_brandModel);
            _unitOfWork.Complete();
            return(RedirectToAction("BrandList", "Brands"));
        }
Exemple #24
0
        public CalcRoutePage(MyList _ml, BrandsViewModel _bvm)
        {
            InitializeComponent();

            animations = new MyAnimations();
            ml         = _ml;
            bvm        = _bvm;

            BindingContext = ml;

            Products.ItemsSource = ml.items;

            HeaderTitle.Text = ml.Topic;

            animations.TranslateStackLayout(APISearch, -Application.Current.MainPage.Width, 0, 0, Easing.Linear);

            //animations.TranslateStackLayout(SearchItems, 0, Application.Current.MainPage.Height, Convert.ToUInt32( Application.Current.MainPage.Height), Easing.CubicOut);

            //Launcher.OpenAsync("geo:0,0?q=394+Pacific+Ave+San+Francisco+CA");
        }
        public ActionResult EditBrand(int id = 0)
        {
            if (!LoginUserSession.Current.IsAdministrator)
            {
                return(RedirectToAction("Edit"));
            }

            BrandRepository repo = new BrandRepository();

            BrandsViewModel brand = new BrandsViewModel();

            Brand brandDb = repo.GetByID(id);

            if (brandDb != null)
            {
                brand = new BrandsViewModel(brandDb);
            }

            return(View(brand));
        }
        public ActionResult Create(BrandsViewModel brandsViewModel)
        {
            brandsViewModel.ShowHideImage = false;

            return(View(brandsViewModel));
        }
Exemple #27
0
 public BrandsPage()
 {
     InitializeComponent();
     BindingContext = new BrandsViewModel();
 }
Exemple #28
0
 public AdminPanelController()
 {
     _adminPanelViewModel = new AdminPanelViewModel();
     _brandsViewModel     = new BrandsViewModel();
     _usersViewModel      = new UsersViewModel();
 }