예제 #1
0
        public string DeleteSubscription(int user, string name)
        {
            GroupActions             groupActions = new GroupActions();
            ConcertNotifierEntities1 concertDB    = new ConcertNotifierEntities1();
            var group = groupActions.FindGroupByName(name);

            string answer = null;
            var    result = concertDB.tblSubscriptions.Where(b => (b.user_id == user) && (b.group_id == group.group_id));

            try
            {
                if (result.ToList().Count() > 0)
                {
                    foreach (var item in result)
                    {
                        concertDB.tblSubscriptions.Remove(item);
                    }
                }
                concertDB.SaveChanges();
                answer = "Исполнитель успешно удален";
            }
            catch (Exception e)
            {
                answer = "У вас нет подписки с таким именем";
                Console.WriteLine(e);
                return(answer);
            }



            return(answer);
        }
예제 #2
0
        public IQueryable <tblSubscriptions> DeleteSubscription(int user, int group_id)
        {
            GroupActions             groupActions = new GroupActions();
            ConcertNotifierEntities1 concertDB    = new ConcertNotifierEntities1();
            var group = groupActions.FindGroupById(group_id);

            if (group == null)
            {
                return(null);
            }


            var Result = concertDB.tblSubscriptions.Where(b => (b.user_id == user) && (b.group_id == group.group_id));

            if (Result != null)
            {
                foreach (var item in Result)
                {
                    concertDB.tblSubscriptions.Remove(item);
                }
                concertDB.SaveChanges();
            }

            return(Result);
        }
예제 #3
0
        public string DeleteAllSubscriptions(int user)
        {
            string answer = "Ваш список подписок очищен";

            try
            {
                ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
                var result = concertDB.tblSubscriptions.Where(b => b.user_id == user);

                if (result != null)
                {
                    foreach (var item in result)
                    {
                        concertDB.tblSubscriptions.Remove(item);
                    }
                    concertDB.SaveChanges();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(answer);
        }
예제 #4
0
        public void UpdateGroup(int id, string name)
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
            tblGroups group = concertDB.tblGroups.Where(b => b.group_id == id).First();

            group.group_name = name;
            concertDB.SaveChanges();
        }
예제 #5
0
        public void InsertSubscription(int user, int group)
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
            var sub  = new tblSubscriptions();
            var subs = SelectAllSubscriptions();

            sub.group_id        = group;
            sub.user_id         = user;
            sub.subscription_id = subs.Count() + 1;
            concertDB.tblSubscriptions.Add(sub);
            concertDB.SaveChanges();
        }
예제 #6
0
        public string InsertUser(int id, string city)
        {
            //ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
            string answer = null;

            try
            {
                var user = new tblUsers();
                user.user_id   = id;
                user.user_city = city;
                concertDB.tblUsers.Add(user);
                concertDB.SaveChanges();
                answer = string.Format("ѕоздравл¤ем с регистрацией, ваш город {0}", city);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw (new Exception());
            }


            return(answer);
        }
예제 #7
0
        public void InsertConcerts(Concert concert, int group)
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
            var conc = new tblConcerts();

            conc.concert_id    = group + 1;
            conc.group_id      = group;
            conc.concert_city  = "Test location";
            conc.concert_date  = System.DateTime.Now;
            conc.concert_link  = "no url";
            conc.concert_place = "place location";
            conc.concert_title = "Test ";

            concertDB.tblConcerts.Add(conc);
            concertDB.SaveChanges();
        }
예제 #8
0
        public void InsertConc(tblConcerts concert, int group)
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
            var conc = new tblConcerts();

            conc.concert_id    = concert.concert_id;
            conc.group_id      = group;
            conc.concert_city  = concert.concert_city;
            conc.concert_date  = concert.concert_date;
            conc.concert_link  = concert.concert_link;
            conc.concert_place = concert.concert_place;
            conc.concert_title = concert.concert_title;

            concertDB.tblConcerts.Add(conc);
            concertDB.SaveChanges();
        }
예제 #9
0
        public void InsertConcert(Concert concert, int group)
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
            var conc = new tblConcerts();

            conc.concert_id    = concert.ID;
            conc.group_id      = group;
            conc.concert_city  = concert.Location;
            conc.concert_date  = concert.Date;
            conc.concert_link  = concert.Link;
            conc.concert_place = concert.Place;
            conc.concert_title = concert.Title;

            concertDB.tblConcerts.Add(conc);
            concertDB.SaveChanges();
        }
예제 #10
0
        public void DeleteAll()
        {
            var subs = concertDB.tblSubscriptions;

            if (subs != null)
            {
                foreach (var item in subs)
                {
                    concertDB.tblSubscriptions.Remove(item);
                }
                concertDB.SaveChanges();
            }

            var concs = concertDB.tblConcerts;

            foreach (var item in concs)
            {
                concertDB.tblConcerts.Remove(item);
            }
            concertDB.SaveChanges();

            var groups = concertDB.tblGroups;

            foreach (var item in groups)
            {
                concertDB.tblGroups.Remove(item);
            }
            concertDB.SaveChanges();

            var users = concertDB.tblUsers;

            foreach (var item in users)
            {
                concertDB.tblUsers.Remove(item);
            }
            concertDB.SaveChanges();
        }