Esempio n. 1
0
        public List <ApplicationStore> GetByStoreTypeMain(string[] applications)
        {
            if (!applications.IsNull() && !applications.Length.IsZero())
            {
                List <ApplicationStore> applicationStores = new List <ApplicationStore>();

                var apps = applicationRepository.Get(applications, true);

                applications.ForEach(applicationName =>
                {
                    var app = apps.SingleOrDefault(x => x.Name == applicationName);

                    if (app.IsNull())
                    {
                        throw new ArgumentException("Ops! A aplicação {0} não existe. :(".ToFormat(applicationName));
                    }

                    var others = applicationStoreRepository.GetByStoreTypeMain(app.Code.Value);

                    if (others.IsNull())
                    {
                        throw new ArgumentException("Ops! A loja não tem permissão a aplicação informada {0}. :(".ToFormat(applicationName));
                    }

                    applicationStores.AddRange(others);
                });

                return(applicationStores);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        public DTO.ApplicationStore GetApplicationStoreByStoreTypeMain(string nameApplication)
        {
            DTO.ApplicationStore result = null;

            var apps = applicationRepository.List().FirstOrDefault(x => x.Name.ToLower() == nameApplication.ToLower());

            if (apps != null)
            {
                var listAppStore = applicationStoreRepository.GetByStoreTypeMain(apps.Code.Value);

                if (!listAppStore.IsNull())
                {
                    var appStore = listAppStore.FirstOrDefault(x => x.Application.Name.ToLower() == nameApplication);
                    if (!appStore.IsNull())
                    {
                        return(new DTO.ApplicationStore(appStore, false));
                    }
                }
            }

            return(result);
        }