Пример #1
0
        public static Dto.Drink GetDrinkById(int id)
        {
            using (var db = new DrinkzAppBDDataContext())
            {
                return db.Drinks.Where(c => c.PK_DRINK == id).Select(c => new Dto.Drink {

                    CREATION_DATE = c.CREATION_DATE,
                    FK_CATEGORY = c.FK_CATEGORY,
                    NAME = c.NAME,
                    DESCRIPTION = c.DESCRIPTION,
                    FK_PROFILE = c.PK_PROFILE,
                    HOWTO = c.HOWTO,
                    LIKES = c.LIKES,
                    PK_DRINK = c.PK_DRINK,
                    VIEWS = c.VIEWS,
                    YOUTUBE_URL = c.YOUTUBE_URL

                }).FirstOrDefault();
            }
        }
Пример #2
0
        public static List<Dto.Drink> GetAllDrinks()
        {
            using (var db = new DrinkzAppBDDataContext())
            {
                return db.Drinks.Select(c=> new Dto.Drink {

                CREATION_DATE = c.CREATION_DATE,
                DESCRIPTION = c.DESCRIPTION,
                FK_CATEGORY = c.FK_CATEGORY,
                NAME = c.NAME,
                FK_PROFILE = c.PK_PROFILE,
                HOWTO = c.HOWTO,
                LIKES = c.LIKES,
                PK_DRINK = c.PK_DRINK,
                VIEWS = c.VIEWS,
                YOUTUBE_URL = c.YOUTUBE_URL

                }).ToList();
            }
        }
Пример #3
0
        public static int CreateNewProfile(Dto.Profile profile)
        {
            using (var db = new DrinkzAppBDDataContext())
            {
                var dbProfile = new Data.Profile()
                {
                    DEVICE_ID = profile.DEVICE_ID,
                    FACEBOOK_ID = profile.FACEBOOK_ID,
                    NAME = profile.NAME,
                    URL_IMAGE = profile.URL_IMAGE,
                    OS_ID = profile.OS_ID
                };

                db.Profiles.InsertOnSubmit(dbProfile);

                db.SubmitChanges();

                return dbProfile.PK_PROFILE;
            }
        }
Пример #4
0
        public static void CreateNewDrink(Dto.Drink drink)
        {
            using (var db = new DrinkzAppBDDataContext())
            {
                var dbDrink = new Data.Drink() {

                    CREATION_DATE = drink.CREATION_DATE,
                    FK_CATEGORY = drink.FK_CATEGORY,
                    NAME = drink.NAME,
                    DESCRIPTION = drink.DESCRIPTION,
                    HOWTO = drink.HOWTO,
                    LIKES = drink.LIKES,
                    PK_PROFILE = drink.FK_PROFILE,
                    VIEWS = drink.VIEWS,
                    YOUTUBE_URL = drink.YOUTUBE_URL,

                };

                db.Drinks.InsertOnSubmit(dbDrink);

                db.SubmitChanges();
            }
        }