public IHttpActionResult Create([FromBody] Entities.Table.Sucursal entity) { try { if (entity != null) { using (var scope = new TransactionScope()) { var save = new Business.Table.Sucursal(entity).Save(); if (save.result.Success) { scope.Complete(); return(Created <Entities.Table.Sucursal>($"{Request.RequestUri}/{save.domain?.Id?.ToString()}", save.domain?.Data?.Entity)); } return(InternalServerError()); } } return(BadRequest()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult Get(int id) { try { var load = new Business.Table.Sucursal() { Id = id }.Load(); if (load.result.Success) { if (load.domain != null) { return(Ok(load.domain?.Data?.Entity)); } return(NotFound()); } return(InternalServerError()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult Update(int id, [FromBody] Entities.Table.Sucursal entity) { try { if (entity != null) { var load = new Business.Table.Sucursal() { Id = id }.Load(); if (load.result.Success) { if (load.domain != null) { load.domain.Entity = entity; using (var scope = new TransactionScope()) { var save = load.domain.Save(); if (save.result.Success) { scope.Complete(); return(Ok(save.domain?.Data?.Entity)); } return(InternalServerError()); } } return(NotFound()); } return(InternalServerError()); } return(BadRequest()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult Delete(int id) { try { var load = new Business.Table.Sucursal() { Id = id }.Load(); if (load.result.Success) { if (load.domain != null) { using (var scope = new TransactionScope()) { var erase = load.domain.Erase(); if (erase.result.Success) { scope.Complete(); return(StatusCode(HttpStatusCode.NoContent)); } return(InternalServerError()); } } return(NotFound()); } return(InternalServerError()); } catch (Exception ex) { return(InternalServerError(ex)); } }