Example #1
0
        public ActionResult edit(BS_Districts district)
        {
            if (String.IsNullOrEmpty(district.DistrictID))
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Missing info"
                }, JsonRequestBehavior.AllowGet));
            }

            var check = db.BS_Districts.Find(district.DistrictID);

            if (check == null)
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Không tìm thấy thông tin"
                }, JsonRequestBehavior.AllowGet));
            }

            check.DistrictName = district.DistrictName;
            check.ProvinceID   = district.ProvinceID;

            db.Entry(check).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();


            return(Json(new ResultInfo()
            {
                error = 0, msg = "", data = check
            }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult create(BS_Districts district)
        {
            if (String.IsNullOrEmpty(district.DistrictID))
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Missing info"
                }, JsonRequestBehavior.AllowGet));
            }

            var check = db.BS_Districts.Find(district.DistrictID);

            if (check != null)
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Đã tồn tại"
                }, JsonRequestBehavior.AllowGet));
            }

            db.BS_Districts.Add(district);

            db.SaveChanges();

            return(Json(new ResultInfo()
            {
                error = 0, msg = "", data = district
            }, JsonRequestBehavior.AllowGet));
        }