public Infrastructure.ApiResponse <Services.ViewModel.MessageViewModel> Post([FromBody] Services.ViewModel.MessageViewModel model) { var response = new Infrastructure.ApiResponse <Services.ViewModel.MessageViewModel>(); try{ var req = new Services.Message.AddMessageRequest(); req.message = model; _messageService.AddMessage(req); response.status = true; response.data = model; response.code = System.Net.HttpStatusCode.Created; }catch (Infrastructure.BusinessRuleException bex) { response.status = true; response.code = System.Net.HttpStatusCode.BadRequest; response.brokenRules = bex.BrokenRules; response.error_message = bex.Message; }catch (Exception ex) { response.status = true; response.code = System.Net.HttpStatusCode.InternalServerError; response.error_message = "Ocorreu um erro inesperado. Entre em contato com o nosso time de desenvolvimento."; } return(response); }
public Infrastructure.ApiResponse <Services.ViewModel.MessageViewModel> Put(string id, [FromBody] Services.ViewModel.MessageViewModel model) { var response = new Infrastructure.ApiResponse <Services.ViewModel.MessageViewModel>(); try{ Guid messageid = Guid.Empty; if (!Guid.TryParse(id, out messageid)) { return(Infrastructure.ApiResponse <Services.ViewModel.MessageViewModel> .CreateResponse(false, "Categoria não encontrada", null, System.Net.HttpStatusCode.NotFound)); } model.Id = messageid; _messageService.UpdateMessage(new Services.Message.UpdateMessageRequest() { message = model }); response.status = true; response.data = model; response.code = System.Net.HttpStatusCode.Created; }catch (Infrastructure.BusinessRuleException bex) { response.status = true; response.code = System.Net.HttpStatusCode.BadRequest; response.brokenRules = bex.BrokenRules; response.error_message = bex.Message; }catch (Exception ex) { response.status = true; response.code = System.Net.HttpStatusCode.InternalServerError; response.error_message = "Ocorreu um erro inesperado. Entre em contato com o nosso time de desenvolvimento."; } return(response); }