コード例 #1
0
        public static void CreateNewFilter(SearchFilterInfo createSearchFilterInfo, out string error)
        {
            try
            {
                using (var ctx = new BotContext())
                {
                    var all = ctx.SearchFilterInfos;

                    if (all.Any())
                    {
                        var existing = ctx.SearchFilterInfos.ToList();

                        if (existing.Any(x => x.FilterName == createSearchFilterInfo.FilterName))
                        {
                            error = "Фильтр с таким именем уже существует";
                            return;
                        }
                    }

                    ctx.SearchFilterInfos.Add(createSearchFilterInfo);

                    ctx.SaveChanges();
                }

                error = "";
            }
            catch (System.Exception e)
            {
                error = e.Message;
            }
        }
コード例 #2
0
        public static void ChangeLoginPassword(string login, string password, out string error)
        {
            try
            {
                using (var ctx = new BotContext())
                {
                    var entity = ctx.LoginPasswords.FirstOrDefault(x => x.Login == login);

                    if (entity == null)
                    {
                        error = "Логин : " + login + " отсутствует.";
                        return;
                    }

                    entity.Password = password;

                    ctx.SaveChanges();
                }

                error = "";
            }
            catch (System.Exception e)
            {
                error = e.Message;
            }
        }
コード例 #3
0
        public static void CreateLoginPassword(string login, string password, out string error)
        {
            try
            {
                using (var ctx = new BotContext())
                {
                    var existEntity = ctx.LoginPasswords.FirstOrDefault(x => x.Login == login);

                    if (existEntity != null)
                    {
                        error = "Логин : " + login + " уже существует.";
                        return;
                    }

                    var entity = new BotLoginPassword()
                    {
                        Login    = login,
                        Password = password,
                    };

                    ctx.LoginPasswords.Add(entity);

                    ctx.SaveChanges();
                }

                error = "";
            }
            catch (System.Exception e)
            {
                error = e.Message;
            }
        }
コード例 #4
0
        public static List <KeyValuePair <string, string> > GetAllLoginsPasswords()
        {
            using (var ctx = new BotContext())
            {
                var entities = ctx.LoginPasswords;

                if (entities.Any())
                {
                    return(entities.ToList().Select(x => new KeyValuePair <string, string>(x.Login, x.Password)).ToList());
                }

                return(new List <KeyValuePair <string, string> >());
            }
        }
コード例 #5
0
 public static List <SearchFilterInfo> GetAllSearchFilters(out string error)
 {
     try
     {
         using (var ctx = new BotContext())
         {
             error = "";
             return(ctx.SearchFilterInfos.ToList());
         }
     }
     catch (System.Exception e)
     {
         error = e.Message;
         return(null);
     }
 }