Exemplo n.º 1
0
        public IActionResult GetProduct(int Phoneid, string[] modelId, string[] models)
        {
            var data = new List <Products>();

            string[] modelsexist = new string[] { }; int[] modelsExists = new int[] { };
            if (modelId[0] != null)
            {
                var    ids         = modelId[0].Split(',');
                int[]  idslist     = Array.ConvertAll(ids, i => int.Parse(i));
                string CompanyName = util.GetAllCompany().FirstOrDefault(x => x.Phoneid == Phoneid).Com_name;
                var    list        = util.getModelList(Phoneid).Where(x => idslist.Contains(x.modelId)).ToList();
                if (!String.IsNullOrEmpty(models[0]))
                {
                    modelsexist       = models[0].Split(',');
                    modelsExists      = Array.ConvertAll(modelsexist, i => int.Parse(i));
                    ViewData["Index"] = modelsExists.Length;
                }
                else
                {
                    ViewData["Index"] = 0;
                }
                var Prices = util.Price(idslist);
                for (int i = 0; i < list.Count(); i++)
                {
                    if (modelsExists.Length == 0 || !modelsExists.Contains(list[i].modelId))
                    {
                        Products p = new Products()
                        {
                            modelId    = list[i].modelId,
                            model_name = list[i].model_name,
                            Phoneid    = Phoneid,
                            com_Name   = CompanyName,
                            price      = Prices.FirstOrDefault(x => x.Item1 == list[i].modelId).Item2,
                            Quantity   = 1,
                        };

                        data.Add(p);
                    }
                }
            }
            return(PartialView("_DisplayOrder", data));
        }
        public JsonResult GetModels(int PhoneId)
        {
            var result = util.getModelList(PhoneId);

            if (result != null)
            {
                return(Json(result));
            }
            else
            {
                return(Json(false));
            }
        }