Пример #1
0
        public Infrastructure.ApiResponse <Services.ViewModel.EscoleteTalkViewModel> Post([FromBody] Services.ViewModel.EscoleteTalkViewModel model)
        {
            var response = new Infrastructure.ApiResponse <Services.ViewModel.EscoleteTalkViewModel>();

            try{
                var req = new Services.Message.AddEscoleteTalkRequest();
                req.escoleteTalk = model;

                _escoleteTalkService.AddEscoleteTalk(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);
        }
Пример #2
0
        public Infrastructure.ApiResponse <Services.ViewModel.EscoleteTalkViewModel> Put(string id, [FromBody] Services.ViewModel.EscoleteTalkViewModel model)
        {
            var response = new Infrastructure.ApiResponse <Services.ViewModel.EscoleteTalkViewModel>();

            try{
                Guid escoleteTalk = Guid.Empty;
                if (!Guid.TryParse(id, out escoleteTalk))
                {
                    return(Infrastructure.ApiResponse <Services.ViewModel.EscoleteTalkViewModel> .CreateResponse(false, "Categoria não encontrada", null, System.Net.HttpStatusCode.NotFound));
                }

                model.Id = escoleteTalk;
                _escoleteTalkService.UpdateEscoleteTalk(new Services.Message.UpdateEscoleteTalkRequest()
                {
                    escoleteTalk = 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);
        }