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>(); } }
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 SofasViewModel(ControllersEnum controllerEnum, ISofaDbContext sofaDb) : base(controllerEnum) { this.AllSofas = sofaDb.AllSofas(); }