public IngStoreSettingsController()
 {
     _storeFactory   = new StoreFactory();
     _factory        = new StoreSettingFactory();
     _factoryCompany = new CompanyFactory();
     //================
     if (CurrentUser != null)
     {
         listOrganization = CurrentUser.ListOrganizationId;
     }
     lstCompany    = _factoryCompany.GetListCompany(listOrganization);
     listCompanyId = lstCompany.Select(x => x.Value).ToList();
     lstStore      = _storeFactory.GetListStore(listOrganization);
 }
Exemple #2
0
        public List <SelectListItem> GetListCompany()
        {
            List <SelectListItem> ListCompany = new List <SelectListItem>();

            try
            {
                CompanyFactory _companyFactory  = new CompanyFactory();
                List <string>  listOrganization = new List <string>();
                if (CurrentUser != null)
                {
                    listOrganization = CurrentUser.ListOrganizationId;
                }
                _companyFactory = new CompanyFactory();
                ListCompany     = _companyFactory.GetListCompany(listOrganization);
            }
            catch (Exception)
            {
            }
            return(ListCompany);
        }
Exemple #3
0
        // Updated 04172018
        public List <SupplierModels> GetDataByListCompany(List <string> ListCompanyId = null, bool?IsActived = null)
        {
            using (NuWebContext cxt = new NuWebContext())
            {
                List <SupplierModels> lstResult = new List <SupplierModels>();

                try
                {
                    if (ListCompanyId == null)
                    {
                        // Get listCompanyId from SESSION
                        if (System.Web.HttpContext.Current.Session["GetListStore_View_V1"] != null)
                        {
                            var listStores = (List <StoreModels>)HttpContext.Current.Session["GetListStore_View_V1"];
                            if (listStores != null && listStores.Any())
                            {
                                ListCompanyId = listStores.Select(ss => ss.CompanyId).Distinct().ToList();
                            }
                        }
                        else
                        {
                            var currentUser = (UserSession)System.Web.HttpContext.Current.Session["User"];
                            if (currentUser != null)
                            {
                                var listOrganization = currentUser.ListOrganizationId;
                                if (listOrganization != null && listOrganization.Any())
                                {
                                    CompanyFactory _companyFactory = new CompanyFactory();
                                    var            listCompany     = _companyFactory.GetListCompany(listOrganization);
                                    if (listCompany != null && listCompany.Any())
                                    {
                                        ListCompanyId = listCompany.Select(ss => ss.Value).Distinct().ToList();
                                    }
                                }
                            }
                        }
                    }

                    if (ListCompanyId != null && ListCompanyId.Any())
                    {
                        lstResult = (from tb in cxt.I_Supplier
                                     where ListCompanyId.Contains(tb.CompanyId) &&
                                     (tb.Status != (int)Commons.EStatus.Deleted && tb.Status != null)
                                     orderby tb.Name
                                     select new SupplierModels()
                        {
                            Id = tb.Id,
                            CompanyId = tb.CompanyId,
                            Name = tb.Name,
                            Phone1 = tb.Phone1,
                            Phone2 = tb.Phone2,
                            Email = tb.Email,
                            IsActived = tb.IsActived,
                            Address = tb.Address
                        }).ToList();

                        if (lstResult != null && lstResult.Any() && IsActived.HasValue)
                        {
                            lstResult = lstResult.Where(ww => ww.IsActived == IsActived.Value).OrderBy(oo => oo.Name).ToList();
                        }
                    }

                    return(lstResult);
                }
                catch (Exception ex)
                {
                    _logger.Error(ex.Message);
                    return(lstResult);
                }
            }
        }