Esempio n. 1
0
        public ActionResult GetThanhphoByTinh(string matinh)
        {
            List <Thanhpho> thanhphos = new List <Thanhpho>();

            if (!string.IsNullOrWhiteSpace(matinh))
            {
                thanhphos = _thanhphoRepository.ListThanhphoByTinh(matinh).ToList();
                if (thanhphos.Count() == 0)
                {
                    var empty = new Thanhpho
                    {
                        Matp  = "",
                        Tentp = "Không có thông tin"
                    };
                    thanhphos.Insert(0, empty);
                }
                else
                {
                    var empty = new Thanhpho
                    {
                        Matp  = "",
                        Tentp = "-- Chọn thông tin --"
                    };
                    thanhphos.Insert(0, empty);
                }
            }

            return(Json(thanhphos));
        }
Esempio n. 2
0
        public ActionResult ThemThanhpho(string matinh)
        {
            var thanhpho = new Thanhpho();

            thanhpho.Matp   = _thanhphoRepository.newMatp(matinh);
            thanhpho.Matinh = matinh;
            return(PartialView(thanhpho));
        }
Esempio n. 3
0
        public void listThanhphoByTinh(string matinh, string selected)
        {
            List <Thanhpho> thanhpho = _thanhphoRepository.ListThanhphoByTinh(matinh).ToList();
            var             empty    = new Thanhpho
            {
                Matp  = "",
                Tentp = "-- Chọn thông tin --"
            };

            thanhpho.Insert(0, empty);
            ViewBag.thanhpho = new SelectList(thanhpho, "Matp", "Tentp", selected);
        }
Esempio n. 4
0
        public ActionResult ThemThanhpho(Thanhpho thanhpho)
        {
            int result = _thanhphoRepository.themThanhpho(thanhpho);

            return(Json(JsonConvert.SerializeObject(result)));
        }