public bool Existe(CqasSexo cqasSexo) { bool respuesta = false; CqasSexo cqasSexo1 = _context.CqasSexo.Where(x => x.Descripcion == cqasSexo.Descripcion).FirstOrDefault(); if (cqasSexo1 != null) { respuesta = true; } return(respuesta); }
public async Task <IActionResult> Edit(string id, CqasSexo cqasSexo) { try { if (!Existe(cqasSexo)) { cqasSexo.Estado = 1; _context.CqasSexo.Update(cqasSexo); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(RedirectToAction("Index", new { mensaje = "El Registro ya Existe" })); } catch (Exception ex) { return(View(cqasSexo)); } }