Exemplo n.º 1
0
        public List <StoreModels> GetListStoreIncludeCompany(List <SelectListItem> lstCompany)
        {
            List <StoreModels> listStores = new List <StoreModels>();

            try
            {
                if (lstCompany.Count > 0)
                {
                    for (int j = 0; j < lstCompany.Count; j++)
                    {
                        string         CompanyID = lstCompany[j].Value;
                        StoreApiModels paraBody  = new StoreApiModels();
                        paraBody.CompanyID = CompanyID;
                        var                result     = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.GetStore, null, paraBody);
                        dynamic            data       = result.Data;
                        var                lstC       = data["ListStore"];
                        var                lstContent = JsonConvert.SerializeObject(lstC /*result.RawData*/);
                        List <StoreModels> lstTmp     = JsonConvert.DeserializeObject <List <StoreModels> >(lstContent);
                        if (lstTmp != null && lstTmp.Count != 0)
                        {
                            var stall14 = lstTmp.Where(ww => ww.StoreCode == Commons.Stall14StoreCode).FirstOrDefault();
                            // Add value common for FJ Daily Sales report
                            if (stall14 != null)
                            {
                                Commons.Stall14StoreId   = stall14.Id;
                                Commons.Stall14StoreName = stall14.Name;
                            }
                            listStores.AddRange(lstTmp);
                        }
                    }
                }
                var currentUser = (UserSession)System.Web.HttpContext.Current.Session["User"];
                if (currentUser != null)
                {
                    listStores = listStores.Where(x => currentUser.ListStoreID.Contains(x.Id)).ToList();
                }
                if (listStores != null && listStores.Any())
                {
                    TaxFactory taxFactory = new TaxFactory();
                    listStores = listStores.OrderBy(s => s.CompanyName).ThenBy(aa => aa.Name).ToList();
                    foreach (var store in listStores)
                    {
                        store.IsIncludeTax = (taxFactory.GetDetailTaxForStore(store.Id) == (int)Commons.ETax.AddOn) ? false : true;
                    }
                }

                return(listStores);
            }
            catch (Exception e)
            {
                NSLog.Logger.Error("GetListStoreIncludeCompany error: ", e);
                return(listStores);
            }
        }
Exemplo n.º 2
0
        public List <string> GetSelectedStoreIDCompany(List <string> ListCompanys)
        {
            List <string> lstStore = new List <string>();

            if (ListCompanys.Count > 0)
            {
                for (int j = 0; j < ListCompanys.Count; j++)
                {
                    string         CompanyID = ListCompanys[j];
                    StoreApiModels paraBody  = new StoreApiModels();
                    //paraBody.AppKey = Commons.AppKey;
                    //paraBody.AppSecret = Commons.AppSecret;
                    //paraBody.CreatedUser = Commons.CreateUser;
                    paraBody.CompanyID = CompanyID;
                    var     result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.GetStore, null, paraBody);
                    dynamic data   = result.Data;
                    var     lstC   = data["ListStore"];

                    var lstContent = JsonConvert.SerializeObject(lstC /*result.RawData*/);
                    var listItems  = JsonConvert.DeserializeObject <List <StoreModels> >(lstContent);
                    if (listItems.Count != 0)
                    {
                        for (int i = 0; i < listItems.Count; i++)
                        {
                            var item = listItems[i];
                            lstStore.Add(item.Id.ToString());
                        }
                    }
                }
            }
            var user = (UserSession)System.Web.HttpContext.Current.Session["User"];

            if (user != null && user.ListStoreID != null)
            {
                lstStore = lstStore.Where(ww => user.ListStoreID.Contains(ww)).ToList();
            }
            return(lstStore);
        }
Exemplo n.º 3
0
        public List <StoreModels> GetListStore_View_V1(List <SelectListItem> lstCompany = null)
        {
            List <StoreModels> listStores = new List <StoreModels>();
            List <StoreModels> listItems  = new List <StoreModels>();

            try
            {
                if (System.Web.HttpContext.Current.Session["GetListStore_View_V1"] != null)
                {
                    listStores = (List <StoreModels>)HttpContext.Current.Session["GetListStore_View_V1"];
                }
                else
                {
                    var currentUser = (UserSession)HttpContext.Current.Session["User"];
                    if (currentUser != null)
                    {
                        if (lstCompany == null || !lstCompany.Any())
                        {
                            var            listOrganizationId = currentUser.ListOrganizationId.ToList();
                            CompanyFactory companyFactory     = new CompanyFactory();
                            lstCompany = companyFactory.GetListCompany(listOrganizationId);
                        }
                        if (lstCompany != null && lstCompany.Any())
                        {
                            for (int j = 0; j < lstCompany.Count; j++)
                            {
                                string         CompanyID = lstCompany[j].Value;
                                StoreApiModels paraBody  = new StoreApiModels();
                                paraBody.CompanyID = CompanyID;
                                var     result     = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.GetStore, null, paraBody);
                                dynamic data       = result.Data;
                                var     lstC       = data["ListStore"];
                                var     lstContent = JsonConvert.SerializeObject(lstC);
                                listItems = JsonConvert.DeserializeObject <List <StoreModels> >(lstContent);
                                if (listItems != null && listItems.Any())
                                {
                                    if (currentUser != null)
                                    {
                                        listItems = listItems.Where(w => currentUser.ListStoreID.Contains(w.Id)).ToList();
                                    }
                                    // Add value common for FJ Daily Sales report
                                    var stall14 = listItems.Where(w => w.StoreCode == Commons.Stall14StoreCode).FirstOrDefault();
                                    if (stall14 != null)
                                    {
                                        Commons.Stall14StoreId   = stall14.Id.ToString();
                                        Commons.Stall14StoreName = stall14.Name;
                                    }
                                    listStores.AddRange(listItems);
                                }
                            }
                            if (listStores != null && listStores.Any())
                            {
                                listStores = listStores.OrderBy(o => o.Name).ToList();

                                System.Web.HttpContext.Current.Session.Add("GetListStore_View_V1", listStores);
                            }
                        }
                    }
                }

                return(listStores);
            }
            catch (Exception e)
            {
                _logger.Error("GetListStore_View_V1: " + e);
                return(listStores);
            }
        }
Exemplo n.º 4
0
        // Get list stores group by company for view
        public List <StoresByCompany> GetListStore_View(List <SelectListItem> lstCompany)
        {
            List <StoresByCompany> listStores = new List <StoresByCompany>();
            List <StoreModels>     listItems  = new List <StoreModels>();

            try
            {
                if (lstCompany.Count > 0)
                {
                    if (System.Web.HttpContext.Current.Session["GetListStore_View"] != null)
                    {
                        listStores = (List <StoresByCompany>)HttpContext.Current.Session["GetListStore_View"];
                    }
                    else
                    {
                        StoresByCompany groupCompany = new StoresByCompany();
                        var             currentUser  = (UserSession)HttpContext.Current.Session["User"];
                        for (int j = 0; j < lstCompany.Count; j++)
                        {
                            string         CompanyID = lstCompany[j].Value;
                            StoreApiModels paraBody  = new StoreApiModels();
                            paraBody.CompanyID = CompanyID;
                            var     result     = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.GetStore, null, paraBody);
                            dynamic data       = result.Data;
                            var     lstC       = data["ListStore"];
                            var     lstContent = JsonConvert.SerializeObject(lstC /*result.RawData*/);
                            listItems = JsonConvert.DeserializeObject <List <StoreModels> >(lstContent);
                            if (listItems.Count != 0)
                            {
                                groupCompany      = new StoresByCompany();
                                groupCompany.text = lstCompany[j].Text;

                                if (currentUser != null)
                                {
                                    listItems = listItems.Where(w => currentUser.ListStoreID.Contains(w.Id)).ToList();
                                }
                                for (int i = 0; i < listItems.Count; i++)
                                {
                                    var item = listItems[i];
                                    groupCompany.children.Add(new StoresChildren()
                                    {
                                        id   = item.Id.ToString(),
                                        text = item.Name
                                    });
                                    // Add value common for FJ Daily Sales report
                                    if (item.StoreCode == Commons.Stall14StoreCode)
                                    {
                                        Commons.Stall14StoreId   = item.Id.ToString();
                                        Commons.Stall14StoreName = item.Name;
                                    }
                                }
                                groupCompany.children = groupCompany.children.OrderBy(o => o.text).ToList();
                                listStores.Add(groupCompany);
                            }
                        }
                        if (listStores != null && listStores.Any())
                        {
                            listStores = listStores.OrderBy(o => o.text).ToList();

                            System.Web.HttpContext.Current.Session.Add("GetListStore_View", listStores);
                        }
                    }
                }
                return(listStores);
            }
            catch (Exception e)
            {
                _logger.Error("GetListStore_View: " + e);
                return(listStores);
            }
        }
Exemplo n.º 5
0
        public List <SelectListItem> GetListStore(List <SelectListItem> lstCompany)
        {
            List <SelectListItem> listStores = new List <SelectListItem>();

            try
            {
                //check to session
                //if (System.Web.HttpContext.Current.Session["GetStoreListSession"] != null)
                //{
                //    listStores = (List<SelectListItem>)System.Web.HttpContext.Current.Session["GetStoreListSession"];
                //}
                //else
                //{
                if (lstCompany.Count > 0)
                {
                    for (int j = 0; j < lstCompany.Count; j++)
                    {
                        string         CompanyID = lstCompany[j].Value;
                        StoreApiModels paraBody  = new StoreApiModels();
                        paraBody.CompanyID = CompanyID;
                        var     result     = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.GetStore, null, paraBody);
                        dynamic data       = result.Data;
                        var     lstC       = data["ListStore"];
                        var     lstContent = JsonConvert.SerializeObject(lstC /*result.RawData*/);
                        var     listItems  = JsonConvert.DeserializeObject <List <StoreModels> >(lstContent);
                        if (listItems.Count != 0)
                        {
                            for (int i = 0; i < listItems.Count; i++)
                            {
                                var item = listItems[i];
                                listStores.Add(new SelectListItem()
                                {
                                    Value = item.Id.ToString(),
                                    Text  = item.Name,
                                });

                                // Add value common for FJ Daily Sales report
                                if (item.StoreCode == Commons.Stall14StoreCode)
                                {
                                    Commons.Stall14StoreId   = item.Id.ToString();
                                    Commons.Stall14StoreName = item.Name;
                                }
                            }
                        }
                    }
                    var currentUser = (UserSession)System.Web.HttpContext.Current.Session["User"];
                    if (currentUser != null)
                    {
                        listStores = listStores.Where(x => currentUser.ListStoreID.Contains(x.Value)).ToList();
                    }
                    if (listStores != null && listStores.Any())
                    {
                        listStores = listStores.OrderBy(s => s.Text).ToList();
                    }
                    //if (listStores != null && listStores.Any())
                    //{
                    //    HttpContext.Current.Session.Add("GetStoreListSession", listStores);
                    //}
                }
                //}
                return(listStores);
            }
            catch (Exception e)
            {
                _logger.Error("Get store list: " + e);
                return(listStores);
            }
        }