Beispiel #1
0
 internal T FindByName(string name)
 {
     using (MethodStoreContext context = new MethodStoreContext())
     {
         return(context.FindByNameAsync <T>(name).Result);
     }
 }
Beispiel #2
0
        internal List <T> GetList()
        {
            List <T> listT = new List <T>();

            using (MethodStoreContext context = new MethodStoreContext())
            {
                Type typeofT = typeof(T);

                if (typeofT == typeof(Models.Group))
                {
                    return(context.Groups.ToList() as List <T>);
                }
                else if (typeofT == typeof(Models.Types))
                {
                    return(context.Types.ToList() as List <T>);
                }
                else if (typeofT == typeof(Models.RemovingText))
                {
                    return(context.RemovingTexts.ToList() as List <T>);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }
Beispiel #3
0
 internal T FindByID(int id)
 {
     using (MethodStoreContext context = new MethodStoreContext())
     {
         return(context.Find(typeof(T), id) as T);
     }
 }
Beispiel #4
0
 internal bool IsEmpty()
 {
     using (MethodStoreContext context = new MethodStoreContext())
     {
         return(!context.RemovingTexts.Any());
     }
 }
Beispiel #5
0
 internal void RemoveMethods(T method)
 {
     using (MethodStoreContext context = new MethodStoreContext())
     {
         context.Remove(method);
         context.SaveChanges();
     }
 }
Beispiel #6
0
        /// <summary>
        /// Инициализирует одноэлементный объект приложения.  Это первая выполняемая строка разрабатываемого
        /// кода; поэтому она является логическим эквивалентом main() или WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            using (EF.MethodStoreContext methodStore = new EF.MethodStoreContext())
            {
                methodStore.InitializingDB();
            }
        }
Beispiel #7
0
        internal void Update(T obj)
        {
            using (MethodStoreContext context = new MethodStoreContext())
            {
                if (obj is Models.Method objMethod)
                {
                    if (objMethod.ID == 0)
                    {
                        context.Add(objMethod);
                    }
                    else
                    {
                        context.Update(objMethod);
                    }
                }
                else if (obj is Models.Group objGroup)
                {
                    if (objGroup.ID == 0)
                    {
                        context.Add(objGroup);
                    }
                    else
                    {
                        context.Update(objGroup);
                    }
                }
                else if (obj is Models.Types objTypes)
                {
                    if (objTypes.ID == 0)
                    {
                        context.Add(objTypes);
                    }
                    else
                    {
                        context.Update(objTypes);
                    }
                }

                context.SaveChanges();
            }
        }
Beispiel #8
0
        internal List <Models.Method> GetListMethods(ParametersSearch parametersSearch)
        {
            GetListMethodsService();

            List <Models.Method> methods = null;

            using (MethodStoreContext context = new MethodStoreContext())
            {
                DbSet <Models.Method> contextMethods = context.Methods;

                IQueryable <Models.Method> contextMethodsSearch = null;

                if (!string.IsNullOrWhiteSpace(parametersSearch.Text))
                {
                    string searchText = parametersSearch.Text;

                    contextMethodsSearch = contextMethods.Where(f =>
                                                                parametersSearch.SearchInGroup && f.Group.Contains(searchText, StringComparison.OrdinalIgnoreCase) ||
                                                                parametersSearch.SearchInType && f.Type.Contains(searchText, StringComparison.OrdinalIgnoreCase) ||
                                                                parametersSearch.SearchInObjectName && f.ObjectName.Contains(searchText, StringComparison.OrdinalIgnoreCase) ||
                                                                parametersSearch.SearchInMethodName && f.MethodName.Contains(searchText, StringComparison.OrdinalIgnoreCase));
                }

                if (contextMethodsSearch == null)
                {
                    contextMethodsSearch = contextMethods.Where(f => true);
                }

                contextMethodsSearch?.OrderByDescending(f => f.ID);
                try
                {
                    methods = contextMethodsSearch?.ToList();
                }
                catch (Exception ex)
                {
                    Messages.Show("При поиске произошла ошибка.\n" + ex.Message);
                }
            }
            return(methods);
        }