Beispiel #1
0
 public SofasController(IConfiguration config, IUtilities utilities, IUserDbContext userDb, ISofaDbContext sofaDb)
     : base(config, utilities, userDb)
 {
     this.config    = config;
     this.utilities = utilities;
     this.userDb    = userDb;
     this.sofaDb    = sofaDb;
 }
Beispiel #2
0
        public EditSofaViewModel(ISofaDbContext sofaDb, int id, int basketCount, int minAmountForSofaToOrder)
            : base(ControllersEnum.Sofas, basketCount)
        {
            this.Sofa = sofaDb.LoadSofaById(id);

            this.MinAmountForSofaToOrder = minAmountForSofaToOrder;

            this.AdditionalImage = sofaDb.AllAdditionalImagesBySofaId(id);
        }
Beispiel #3
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;
 }
        public ListOfSofas(ISofaDbContext sofasDb, int basketCount)
            : base(ControllersEnum.Sofas, basketCount)
        {
            List <Sofa> SofasNotOrder = sofasDb.AllSofas();

            if (SofasNotOrder != null)
            {
                this.Sofas = SofasNotOrder.OrderBy(x => x.NewPrice != null ? x.NewPrice : x.Price).ToList();
            }
            else
            {
                this.Sofas = new List <Sofa>();
            }
        }
Beispiel #5
0
 public EditSofaViewModel(ISofaDbContext sofaDb, int id)
     : base(ControllersEnum.Sofas)
 {
     this.Sofa = sofaDb.LoadSofaById(id);
 }
 public SofasViewModel(ControllersEnum controllerEnum, ISofaDbContext sofaDb)
     : base(controllerEnum)
 {
     this.AllSofas = sofaDb.AllSofas();
 }
Beispiel #7
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 AdditionalImagesSofaViewModel(ISofaDbContext sofaDb, int Id)
     : base(ControllersEnum.Sofas)
 {
     this.ChairsImages = sofaDb.LoadAllAdditionalImagesSofa(Id);
     this.SofaId       = Id;
 }