public ListOfChairsViewModel(IChairDbContext chairDb, int basketCount)
            : base(ControllersEnum.Chairs, basketCount)
        {
            List <Chair> chairsNotOrder = chairDb.AllChairs();

            this.Chairs = chairsNotOrder.OrderBy(x => x.NewPrice != null ? x.NewPrice : x.Price).ToList();
        }
示例#2
0
 public ChairsController(IConfiguration config, IUtilities utilities, IUserDbContext userDb, IChairDbContext chairDb) : base(config, utilities, userDb)
 {
     this.config    = config;
     this.utilities = utilities;
     this.userDb    = userDb;
     this.chairDb   = chairDb;
 }
示例#3
0
        public EditChairViewModel(ControllersEnum controller, int id, IChairDbContext chairDb)
            : base(controller)
        {
            this.Chair = chairDb.Edit(id);

            this.AdditionalImages = chairDb.AllAdditionalImagesByChairId(id);
        }
示例#4
0
        public EditChairViewModel(IChairDbContext chairDbContext, int id, int basketElementCount, int minAmoutToOrderChair)
            : base(ControllersEnum.Chairs, basketElementCount)
        {
            this.Chair = chairDbContext.Edit(id);

            this.MinAmoutToOrderChair = minAmoutToOrderChair;

            this.AdditionalChairImages = chairDbContext.AllAdditionalImagesByChairId(id);
        }
示例#5
0
 public SearchController(IConfiguration config, IUtilities utilities, IUserDbContext userDb, IArmchairDbContext armchairDb,
                         IChairDbContext chairDb, ICubeSeatDbContext cubeSeatDb, ISofaDbContext sofaDb)
     : base(config, utilities, userDb)
 {
     this.config     = config;
     this.utilities  = utilities;
     this.userDb     = userDb;
     this.armchairDb = armchairDb;
     this.chairDb    = chairDb;
     this.cubeSeatDb = cubeSeatDb;
     this.sofaDb     = sofaDb;
 }
示例#6
0
        public SearchViewModel(IArmchairDbContext armchairDb, IChairDbContext chairDb, ICubeSeatDbContext cubeSeatDb, ISofaDbContext sofaDb, string searchPattern, int basketCount, PriceSortBy?orderBy)
            : base(ControllersEnum.Search, basketCount)
        {
            if (!orderBy.HasValue)
            {
                this.Armchairs = armchairDb.AllArmchairs().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).ToList();

                this.CubeSeat = cubeSeatDb.AllCubeSeat().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).ToList();

                this.Sofas = sofaDb.AllSofas().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).ToList();

                this.Chairs = chairDb.AllChairs().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).ToList();
            }
            else
            {
                if (orderBy.Value == PriceSortBy.ASC)
                {
                    this.Armchairs = armchairDb.AllArmchairs().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).OrderBy(x => x.NewPrice != null ? x.NewPrice : x.Price).ToList();

                    this.CubeSeat = cubeSeatDb.AllCubeSeat().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).OrderBy(x => x.NewPrice != null ? x.NewPrice : x.Price).ToList();

                    this.Sofas = sofaDb.AllSofas().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).OrderBy(x => x.NewPrice != null ? x.NewPrice : x.Price).ToList();

                    this.Chairs = chairDb.AllChairs().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).OrderBy(x => x.NewPrice != null ? x.NewPrice : x.Price).ToList();
                }
                else if (orderBy.Value == PriceSortBy.DESC)
                {
                    this.Armchairs = armchairDb.AllArmchairs().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).OrderByDescending(x => x.NewPrice != null ? x.NewPrice : x.Price).ToList();

                    this.CubeSeat = cubeSeatDb.AllCubeSeat().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).OrderByDescending(x => x.NewPrice != null ? x.NewPrice : x.Price).ToList();

                    this.Sofas = sofaDb.AllSofas().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).OrderByDescending(x => x.NewPrice != null ? x.NewPrice : x.Price).ToList();

                    this.Chairs = chairDb.AllChairs().Where(x => x.Name.ToUpper().Contains(searchPattern.ToUpper())).OrderByDescending(x => x.NewPrice != null ? x.NewPrice : x.Price).ToList();
                }
            }
        }
 public ChairsViewModel(IChairDbContext chairDb, ControllersEnum controllerEnum)
     : base(controllerEnum)
 {
     this.Chairs = chairDb.AllChairs();
 }
示例#8
0
 public AdditionalImagesChairViewModel(int id, IChairDbContext chairDb)
     : base(ControllersEnum.Chairs)
 {
     this.ChairId      = id;
     this.ChairsImages = chairDb.LoadAllAdditionalImagesChair(id);
 }