Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 6
0
        public bool ContainsGroup(string name)
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
            var result = concertDB.tblGroups.Where(b => b.group_name == name);

            if (result.Count() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        public tblConcerts FindGroupIdByConcert(int id)
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
            var result = concertDB.tblConcerts.Where(b => b.concert_id == id);

            if (result.Count() > 0)
            {
                return(result.First());
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 8
0
        public tblGroups FindGroupByName(string name)
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
            var result = concertDB.tblGroups.Where(b => b.group_name == name);

            if (result.Count() > 0)
            {
                return(result.First());
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        public tblUsers FindUser(int id)
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();
            var result = concertDB.tblUsers.Where(b => b.user_id == id);

            if (result.Count() > 0)
            {
                return(result.First());
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 10
0
        public bool ContainsSubscription(string name, int user)
        {
            ConcertNotifierEntities1 concertDB    = new ConcertNotifierEntities1();
            GroupActions             groupActions = new GroupActions();
            var group  = groupActions.FindGroupByName(name);
            var result = concertDB.tblSubscriptions.Where(b => (b.group_id == group.group_id) && (b.user_id == user));

            if (result.Count() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 11
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();
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
0
        public IList <tblSubscriptions> SelectSubscriptions(int user)
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();

            return(concertDB.tblSubscriptions.Where(b => b.user_id == user).ToList());
        }
Exemplo n.º 15
0
        public DbSet <tblConcerts> SelectAllConcerts()
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();

            return(concertDB.tblConcerts);
        }
Exemplo n.º 16
0
        public DbSet <tblSubscriptions> SelectAllSubscriptions()
        {
            ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1();

            return(concertDB.tblSubscriptions);
        }
Exemplo n.º 17
0
 public GroupActions(ConcertNotifierEntities1 context)
 {
     concertDB = context;
 }