public IHttpActionResult Create([FromBody] Entities.Table.Empresa entity) { try { if (entity != null) { using (var scope = new TransactionScope()) { var save = new Business.Table.Empresa(entity).Save(); if (save.result.Success) { scope.Complete(); return(Created <Entities.Table.Empresa>($"{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.Empresa() { Id = id }.Load(); if (load.result.Success) { if (load.domain != null) { load.domain.Sucursales_Refresh(); return(Ok(load.domain?.Data?.Entity)); } return(NotFound()); } return(InternalServerError()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public virtual (Result result, Business.Table.Empresa domain) Empresa_Refresh(int maxdepth = 1, Business.Query.Empresa query = null) { var refresh = Data.Empresa_Refresh(maxdepth, query?.Data); Empresa = new Business.Table.Empresa(refresh.data); return(refresh.result, _empresa); }
public IHttpActionResult Update(int id, [FromBody] Entities.Table.Empresa entity) { try { if (entity != null) { var load = new Business.Table.Empresa() { 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.Empresa() { 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)); } }
public override Business.Table.Empresa LoadX(Business.Table.Empresa domain, int maxdepth = 1, int depth = 0) { domain.Tipo = "0"; return(domain); }