Beispiel #1
0
        public string AddingCityToUser(int id, string city)
        {
            UserActions userActions = new UserActions();
            string      answer      = null;

            try
            {
                if (userActions.ContainsUser(id))
                {
                    userActions.UpdateUser(id, city);
                    answer = String.Format("¬аш город обновлен, теперь вы находитесь в городе {0}", city);
                }
                else
                {
                    userActions.InsertUser(id, city);
                    answer = String.Format("¬ы зарегестрированы в городе {0}", city);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception();
            }


            return(answer);
        }
Beispiel #2
0
        public string ShowConcList(int user, string user_city)
        {
            UserActions         userActions         = new UserActions();
            SubscriptionActions subscriptionActions = new SubscriptionActions();

            GroupActions groupActions = new GroupActions();
            bool         atleastone   = false;
            string       answer       = null;

            if (userActions.ContainsUser(user))
            {
                var select = subscriptionActions.SelectSubscriptions(user);
                if (select != null)
                {
                    DbSet <tblConcerts> concerts = SelectAllConcerts();

                    int i = 0;
                    foreach (var item in select)
                    {
                        var id   = item.group_id;
                        var find = groupActions.FindGroupById(id);

                        if (find != null)
                        {
                        }
                        else
                        {
                            answer = "Не найдено ни одного концерта в вашем городе у исполнителей из вашего списка подписок ";
                        }

                        for (i = 0; i < concerts.Count(); i++)
                        {
                            foreach (var conc in concerts)
                            {
                                if (conc.concert_city == user_city)
                                {
                                    answer += String.Format(
                                        "Инфо о концерте группы {0} Название: {1} Место: {2} Время: " +
                                        "{3} Ссылка на источник: {4} \n", conc.group_id, conc.concert_title,
                                        conc.concert_city, conc.concert_date, conc.concert_link);
                                    atleastone = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    answer = "Добавьте группу с помощью команды \"/add <Группа>\".";
                }
            }

            if (atleastone == false)
            {
                answer = "Не найдено ни одного концерта в вашем городе у исполнителей из вашего списка подписок";
            }
            return(answer);
        }
Beispiel #3
0
        public string ShowSubList(int user)
        {
            UserActions  userActions  = new UserActions();
            GroupActions groupActions = new GroupActions();

            string answer = null;


            if (userActions.ContainsUser(user))
            {
                var select = SelectSubscriptions(user);
                if (select != null)
                {
                    int i = 1;
                    foreach (var item in select)
                    {
                        var id   = item.group_id;
                        var find = groupActions.FindGroupById(id);
                        if (find != null)
                        {
                            var name = find.group_name;
                            answer += string.Format("{0}) {1}\n", i++, name);
                        }
                        else
                        {
                            answer = "Добавьте группу с помощью команды \"/add <Группа>\".";
                        }
                    }

                    if (select.Count() == 0)
                    {
                        answer = "Добавьте группу с помощью команды \"/add <Группа>\".";
                    }
                }
            }
            else
            {
                answer = "Пользователь с таким id не найден. Добавьте город с помощью \"/city";
            }

            return(answer);
        }