Ejemplo n.º 1
0
 public async Task <IActionResult> Save([FromBody] ArvoreViewModel model)
 {
     try
     {
         return(Ok(await _ArvoreService.Insert(_mapper.Map <Arvore>(model))));
     }
     catch (Exception e) {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Update([FromBody] ArvoreViewModel model)
        {
            try
            {
                var arvore = _ArvoreService.GetSingle(x => x.Id == model.Id, true);
                if (arvore == null)
                {
                    return(NotFound());
                }

                return(Ok(await _ArvoreService.Update(_mapper.Map <Arvore>(model))));
            }
            catch (Exception e) {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Delete([FromBody] ArvoreViewModel model)
        {
            try
            {
                var arvore = await _ArvoreService.GetSingle(x => x.Id == model.Id, true);

                if (arvore == null)
                {
                    return(NotFound());
                }

                return(Ok(await _ArvoreService.Delete((long)model.Id)));
            }
            catch (Exception e) {
                return(BadRequest(e.Message));
            }
        }