Esempio n. 1
0
        // GET: Khuyenmais/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            HttpResponseMessage response = await client.GetAsync(url + @"ChiTietKhuyenMais/" + id);

            if (response.IsSuccessStatusCode)
            {
                var responseData = response.Content.ReadAsStringAsync().Result;
                var settings     = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };
                var ChiTietKhuyenMais        = JsonConvert.DeserializeObject <List <ChiTietKhuyenMai> >(responseData, settings);
                List <ChiTietKhuyenMai> dskm = ChiTietKhuyenMais.ToList();
                ViewBag.MaKM = id;


                // Get km
                HttpResponseMessage responseMessage = await client.GetAsync(url + @"KhuyenMais/");

                List <Khuyenmai> khuyenmais = getAllKhuyenmai(responseMessage);
                Khuyenmai        km         = khuyenmais.SingleOrDefault(n => n.MaKM == id);


                //getch
                responseMessage = await client.GetAsync(url + @"Cuahangs/");

                List <Cuahang> listch    = CuahangsController.getAllCuaHang(responseMessage);
                List <string>  dscuahang = new List <string>();
                ViewBag.tench = dscuahang;
                //get sp
                responseMessage = await client.GetAsync(url + @"Doans/");

                List <Doan>   listda = DoansController.getAllDoan(responseMessage);
                List <string> dsTen  = new List <string>();
                foreach (ChiTietKhuyenMai ctkm in dskm)
                {
                    string name = listda.Where(n => n.MaDA == ctkm.MaDA).SingleOrDefault().TenDA;
                    dsTen.Add(name);
                }
                ViewBag.nameDa = dsTen;
                return(View(ChiTietKhuyenMais.ToList()));
            }
            return(View());
        }
        // GET: Danhmucdoans/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            Danhmucdoan         danhmucdoans = null;
            HttpResponseMessage response     = await client.GetAsync(url + @"Danhmucdoans/" + id);

            if (response.IsSuccessStatusCode)
            {
                //dong hoac mo data table
                danhmucdoans = await response.Content.ReadAsAsync <Danhmucdoan>();

                ViewBag.accept = false;

                // Call api
                HttpResponseMessage responseMessage = await client.GetAsync(url + @"Doans/");

                List <Doan> doans = DoansController.getAllDoan(responseMessage);
                // Check data with id customer
                doans      = doans.Where(n => n.MaDM == id).ToList();
                ViewBag.da = doans;
            }
            return(View(danhmucdoans));
        }