Пример #1
0
 public static int GetNumberOfDrinksByType(int type)
 {
     using (var db = new DrinkDataBaseDataContext())
     {
         return db.DRINKs.Where(c => c.FK_TYPE== type).Count();
     }
 }
Пример #2
0
        public static List<Dto.Type> SelectAllTypes()
        {
            using (var db = new DrinkDataBaseDataContext())
            {
                return db.TYPEs.Select(c => new Dto.Type {

                    NAME = c.NAME,
                    PK_TYPE = c.PK_TYPE

                }).ToList();
            }
        }
Пример #3
0
        public static Dto.Type GetTypeName(int Id)
        {
            using (var db = new DrinkDataBaseDataContext())
            {
                return db.TYPEs.Where(c => c.PK_TYPE == Id).Select(c=>new Dto.Type {

                    PK_TYPE = c.PK_TYPE,
                    NAME = c.NAME

                    }).FirstOrDefault();
            }
        }
Пример #4
0
        public static List<Dto.Size> SelectAllSizes()
        {
            using (var db = new DrinkDataBaseDataContext())
            {
                return db.SIZEs.Select(c => new Dto.Size {

                    SIZETYPE = c.SIZETYPE,
                    PK_SIZE  = c.PK_SIZE

                }).ToList();
            }
        }
Пример #5
0
        public static Dto.Size GetSizeName(int Id)
        {
            using (var db = new DrinkDataBaseDataContext())
            {
                return db.SIZEs.Where(c => c.PK_SIZE == Id).Select(c => new Dto.Size {

                    PK_SIZE = c.PK_SIZE,
                    SIZETYPE = c.SIZETYPE

                }).FirstOrDefault();
            }
        }
Пример #6
0
        public static List<Dto.Drink> SelectAllDrinks()
        {
            using (var db = new DrinkDataBaseDataContext())
            {
                return db.DRINKs.Select(c => new Dto.Drink {

                    FK_SIZE = c.FK_SIZE,
                    NAME = c.NAME,
                    FK_TYPE = c.FK_TYPE,
                    PHOTO = c.PHOTO.ToArray(),
                    PRICE = c.PRICE,
                    PK_DRINK = c.PK_DRINK

                }).ToList();
            }
        }
Пример #7
0
        public static void CreateNewDrink(Dto.Drink drink)
        {
            using (var db = new DrinkDataBaseDataContext())
            {
                var dbDrink = new Data.DRINK()
                {
                    FK_SIZE = drink.FK_SIZE,
                    NAME = drink.NAME,
                    FK_TYPE = drink.FK_TYPE,
                    PHOTO = drink.PHOTO,
                    PRICE = drink.PRICE
                };

                db.DRINKs.InsertOnSubmit(dbDrink);

                db.SubmitChanges();
            }
        }