Exemplo n.º 1
0
        private List <Models.ElementStore> GetElementsStores()
        {
            List <Models.ElementStore> list = SafeResult <List <Models.ElementStore> > .SafeAction(
                ()
                => ElementStores.OrderByDescending(f => f.ID).ToList());

            return(list);
        }
Exemplo n.º 2
0
        private static string GetConnectionString()
        {
            string connectionString = SafeResult <string> .SafeAction(() => GetConnectionStringSafeAction());

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new CreateConnectionStringException();
            }

            if (!CheckConnectionDataSouce(connectionString))
            {
                throw new PingConnectionException("При проверке подключения к базе данных 'Method store' произошла ошибка.\n" +
                                                  "Проверьте строку подключения и наличие соединения к серверу.");
            }

            return(connectionString);
        }
Exemplo n.º 3
0
        private bool UpdateElementStores(Models.ElementStore elementStore)
        {
            if (elementStore.ID == 0)
            {
                Models.ElementStore savedElement = ElementStores.Add(elementStore);
                elementStore.ID = savedElement.ID;
            }
            else
            {
                Models.ElementStore findedElement = GetElementStores(elementStore.ID);

                findedElement.Fill(elementStore);
            }

            bool result = SafeResult <bool> .SafeAction(
                () =>
            {
                SaveChanges();
                return(true);
            });

            return(result);
        }
Exemplo n.º 4
0
        private Models.ElementStore GetElementStores(int id)
        {
            Models.ElementStore elementStore = SafeResult <Models.ElementStore> .SafeAction(() => ElementStores.FirstOrDefault(f => f.ID == id));

            return(elementStore);
        }