public HttpResponseMessage Insert(PatrocinioModel model) { try { business.Insert(ModelToEntity(model)); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message.ToString())); } }
private PatrocinioEntity ModelToEntity(PatrocinioModel model) { return(new PatrocinioEntity() { Seguradora = new SeguradoraEntity() { Id = model.SeguradoraId }, Representante = new RepresentanteEntity() { Id = model.RepresentanteId } }); }
public HttpResponseMessage Update(int id, PatrocinioModel model) { try { PatrocinioEntity patrocinio = ModelToEntity(model); patrocinio.Id = id; business.Update(patrocinio); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message.ToString())); } }