public Infrastructure.ApiResponse <Services.ViewModel.PersonalityQuestionViewModel> Post([FromBody] Services.ViewModel.PersonalityQuestionViewModel model) { var response = new Infrastructure.ApiResponse <Services.ViewModel.PersonalityQuestionViewModel>(); try{ var req = new Services.Message.AddPersonalityQuestionRequest(); req.personalityQuestion = model; _personalityQuestionService.AddPersonalityQuestion(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.PersonalityQuestionViewModel> Put(string id, [FromBody] Services.ViewModel.PersonalityQuestionViewModel model) { var response = new Infrastructure.ApiResponse <Services.ViewModel.PersonalityQuestionViewModel>(); try{ Guid questionId = Guid.Empty; if (!Guid.TryParse(id, out questionId)) { return(Infrastructure.ApiResponse <Services.ViewModel.PersonalityQuestionViewModel> .CreateResponse(false, "Categoria não encontrada", null, System.Net.HttpStatusCode.NotFound)); } model.Id = questionId; _personalityQuestionService.UpdatePersonalityQuestion(new Services.Message.UpdatePersonalityQuestionRequest() { personalityQuestion = 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); }