/// <summary> /// POST: Inclui um DDD /// </summary> /// <param name="obj">Objeto com os dados do DDD à ser inserido</param> /// <returns></returns> public HttpResponseMessage Post(DDDViewModel obj) { try { if (ModelState.IsValid) { _dddAppService.Incluir(obj); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, obj); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = obj.DDDId })); return(response); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
/// <summary> /// PUT: Altera um DDD /// </summary> /// <param name="id">Identificador do DDD</param> /// <param name="obj">Todos os outros dados deste DDD</param> /// <returns></returns> public HttpResponseMessage Put(int id, DDDViewModel obj) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != obj.DDDId) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } try { _dddAppService.Alterar(obj); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public void Alterar(DDDViewModel objViewModel) { _dddService.Alterar(Mapper.Map <DDD>(objViewModel)); }
public void Incluir(DDDViewModel objViewModel) { var usu = Mapper.Map <DDD>(objViewModel); _dddService.Incluir(usu); }
public IEnumerable <DDDViewModel> Filtros(DDDViewModel objViewModel) { return(Mapper.Map <IEnumerable <DDDViewModel> >(_dddService.Filtros(Mapper.Map <DDD>(objViewModel)))); }