public ActionResult edit(BS_Countries country) { if (String.IsNullOrEmpty(country.CountryID)) { return(Json(new ResultInfo() { error = 1, msg = "Missing info" }, JsonRequestBehavior.AllowGet)); } var check = db.BS_Countries.Find(country.CountryID); if (check == null) { return(Json(new ResultInfo() { error = 1, msg = "Không tìm thấy thông tin" }, JsonRequestBehavior.AllowGet)); } check.CountryName = country.CountryName; check.CountryCode = country.CountryCode; check.IsActive = country.IsActive; check.UpdateDate = DateTime.Now; db.Entry(check).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Json(new ResultInfo() { error = 0, msg = "", data = check }, JsonRequestBehavior.AllowGet)); }
public ActionResult create(BS_Countries country) { if (String.IsNullOrEmpty(country.CountryID)) { return(Json(new ResultInfo() { error = 1, msg = "Missing info" }, JsonRequestBehavior.AllowGet)); } var check = db.BS_Countries.Find(country.CountryID); if (check != null) { return(Json(new ResultInfo() { error = 1, msg = "Đã tồn tại" }, JsonRequestBehavior.AllowGet)); } country.IsActive = true; country.CreateDate = DateTime.Now; db.BS_Countries.Add(country); db.SaveChanges(); return(Json(new ResultInfo() { error = 0, msg = "", data = country }, JsonRequestBehavior.AllowGet)); }