Example #1
0
        public static List <Cars> getCars()
        {
            CarsDBEntities context = new CarsDBEntities();
            var            res     = new List <Cars>();

            var test = context.Cars
                       .Where(e => e.Id != 0)
                       .Select(e => new
            {
                name         = e.Name,
                model        = e.Model,
                transmission = e.Transmission,
                gaztype      = e.GazType,
                enginelitres = e.EngineLitres,
                typeofcar    = e.TypeOfCar,
                discount     = e.Discount,
                photo1       = e.Photo1,
                price        = e.Price,
                photo2       = e.Photo2,
                photo3       = e.Photo3
            });


            foreach (var item in test)
            {
                res.Add(new Cars {
                    Name = item.name, Model = item.model, Transmission = item.transmission, GazType = item.gaztype, EngineLitres = item.enginelitres, TypeOfCar = item.typeofcar, Discount = item.discount, Photo1 = item.photo1, Price = item.price, Photo2 = item.photo2, Photo3 = item.photo3
                });
            }
            return(res);
        }
Example #2
0
        public static List <Accounts> GetAccounts()
        {
            CarsDBEntities context = new CarsDBEntities();
            var            res     = new List <Accounts>();

            var test = context.Accounts
                       .Select(e => new
            {
                login    = e.Login,
                password = e.Password,
                email    = e.Email,
                isadmin  = e.IsAdmin
            });


            foreach (var item in test)
            {
                res.Add(new Accounts {
                    Login = item.login, Password = item.password, Email = item.email, IsAdmin = item.isadmin
                });
            }
            return(res);
        }