public bool Update(Model.Mascota model) { bool success = false; if (model == null) { return(false); } try { using (var ctx = new PetZooContext()) { ctx.Mascota.Attach(model); ctx.Entry(model).State = EntityState.Modified; success = ctx.SaveChanges() > 0; } } catch (Exception) { //log } return(success); }
public long Add(Model.Mascota model) { if (model == null) { return(0); } try { using (var ctx = new PetZooContext()) { ctx.Mascota.Add(model); ctx.SaveChanges(); } } catch (Exception) { //log } return(model.IdMascota); }