public async virtual Task <IHttpActionResult> Post([FromBody] AutorTelefone model) { try { // validate if (model == null) { return(BadRequest("Model can not be null.")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // add entity if (await FacadeBO.AutorTelefone.AddAsync(model) == 0) { return(Conflict()); } // registry created return(Created <object>(Request.RequestUri + model.Id.ToString(), model.Id)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async virtual Task <IHttpActionResult> Put(int id, [FromBody] AutorTelefone model) { try { // validate if (model == null) { return(BadRequest("Model can not be null.")); } if (id == 0) { return(BadRequest("Identifier is required.")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (await FacadeBO.AutorTelefone.GetByIdAsync(id) == null) { return(NotFound()); } // defines identifier for model change model.Id = id; // modify entity if (await FacadeBO.AutorTelefone.ModifyAsync(model) == 0) { return(NotFound()); } return(Ok()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async virtual Task <IHttpActionResult> Get([FromUri] PaggingCriteria <AutorTelefone> pagging, [FromUri] AutorTelefone model) { try { if (pagging == null) { pagging = new PaggingCriteria <AutorTelefone>(); } // partial filters var clauseExpr = PredicateBuilder.True <AutorTelefone>(); if (model != null) { ApplyListFilter(model, ref clauseExpr); } // partial pagging ApplyListPagging(pagging); // get by filters var result = await FacadeBO.AutorTelefone.GetByAsync(clauseExpr, pagging); if (result == null || result.Data.Count == 0) { return(NotFound()); } SetLinkPaging("autortelefone_get", result, pagging); result.Links.Add(GetLinkSelf("autortelefone_get", result, pagging)); result.Links.Add(GetLinkItem("autortelefone_get_id")); result.Links.Add(GetLinkItemCreate("autortelefone_add")); result.Links.Add(GetLinkItemEdit("autortelefone_modify")); result.Links.Add(GetLinkItemDelete("autortelefone_delete")); return(Ok(result)); } catch (Exception ex) { return(InternalServerError(ex)); } }
/// <summary> /// Apply filter for listing /// </summary> partial void ApplyListFilter(AutorTelefone model, ref Expression <Func <AutorTelefone, bool> > clause);