public async Task <IActionResult> AddDictionaryItem([Bind("title,content,dictionaryType")] Services.ViewModel.DictionaryViewModel model)
        {
            Infrastructure.ApiResponse <bool> favoriteresponse = null;
            model.userId = Guid.Parse(getClaimValue("Id"));
            System.Net.Http.HttpMethod method = System.Net.Http.HttpMethod.Post;
            favoriteresponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <bool> >(
                Helpers.EscolaDeVoceEndpoints.Dictionary.get,
                method,
                JsonConvert.SerializeObject(model)
                );

            return(View());
        }
예제 #2
0
        public Infrastructure.ApiResponse <Services.ViewModel.DictionaryViewModel> Put(string id, [FromBody] Services.ViewModel.DictionaryViewModel model)
        {
            var response = new Infrastructure.ApiResponse <Services.ViewModel.DictionaryViewModel>();

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

                model.Id = dictionaryId;
                _dictionaryService.UpdateDictionary(new Services.Message.UpdateDictionaryRequest()
                {
                    dictionary = 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);
        }
예제 #3
0
        public Infrastructure.ApiResponse <Services.ViewModel.DictionaryViewModel> Post([FromBody] Services.ViewModel.DictionaryViewModel model)
        {
            var response = new Infrastructure.ApiResponse <Services.ViewModel.DictionaryViewModel>();

            try{
                var req = new Services.Message.AddDictionaryRequest();
                req.dictionary = model;

                _dictionaryService.AddDictionary(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);
        }