public IHttpActionResult PutComprobante(int id, Comprobante comprobante) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != comprobante.ComprobanteId) { return(BadRequest()); } db.Entry(comprobante).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ComprobanteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutMenu(int id, Menu menu) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != menu.MenuId) { return(BadRequest()); } db.Entry(menu).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MenuExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutEmpleado(int id, Empleado empleado) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != empleado.EmpleadoId) { return(BadRequest()); } db.Entry(empleado).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmpleadoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/* private static UnityOfWork _Instance; * private static readonly object _Lock = new object(); * public static UnityOfWork Instance * { * get * { * lock (_Lock) * { * if (_Instance == null) * { * _Instance = new UnityOfWork(); * } * } * * return _Instance; * } * }*/ public int SaveChanges() { return(_Context.SaveChanges()); }