Пример #1
0
 public JsonResult Editar(tbl_Morador morador)
 {
     //if (db.tbl_Morador.Any(x => x.CPF == morador.CPF))
     //{
     //    return Json(false, JsonRequestBehavior.AllowGet);
     //}
     db.Entry(morador).State = EntityState.Modified;
     db.SaveChanges();
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Пример #2
0
        public JsonResult Salvar(tbl_Morador morador)
        {
            if (db.tbl_Morador.Any(x => x.CPF == morador.CPF))
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }

            db.Configuration.ValidateOnSaveEnabled = false;
            db.tbl_Morador.Add(morador);
            db.SaveChanges();
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        public JsonResult Deletar(int id)
        {
            try
            {
                tbl_Morador morador = db.tbl_Morador.Where(x => x.ID == id).FirstOrDefault();

                if (morador != null)
                {
                    db.tbl_Morador.Remove(morador);
                    db.SaveChanges();
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }