public IActionResult Delete([FromBody] EstablecimientoCategoriaDTO establecimientoCategoriaDTO)
        {
            ResponseQuery responseQuery = new ResponseQuery();

            if (establecimientoCategoriaDTO.co_establecimiento_clase == "")
            {
                responseQuery.error_number  = -1;
                responseQuery.error_message = "co_establecimiento_clase tiene un valor errado o nulo.";
                return(BadRequest(responseQuery));
            }
            if (establecimientoCategoriaDTO.co_establecimiento_subclase == "")
            {
                responseQuery.error_number  = -1;
                responseQuery.error_message = "co_establecimiento_subclase tiene un valor errado o nulo.";
                return(BadRequest(responseQuery));
            }
            if (establecimientoCategoriaDTO.co_establecimiento_categoria == "")
            {
                responseQuery.error_number  = -1;
                responseQuery.error_message = "co_establecimiento_categoria tiene un valor errado o nulo.";
                return(BadRequest(responseQuery));
            }

            responseQuery = _establecimientoCategoriaApplication.Delete(establecimientoCategoriaDTO);
            if (responseQuery.error_number == 0)
            {
                return(Ok(responseQuery));
            }

            return(BadRequest(responseQuery));
        }
        public async Task <IActionResult> GetAsync([FromBody] EstablecimientoCategoriaDTO establecimientoCategoriaDTO)
        {
            if (establecimientoCategoriaDTO.co_establecimiento_clase == "")
            {
                return(BadRequest());
            }

            if (establecimientoCategoriaDTO.co_establecimiento_subclase == "")
            {
                return(BadRequest());
            }

            if (establecimientoCategoriaDTO.co_establecimiento_categoria == "")
            {
                return(BadRequest());
            }

            var response = await _establecimientoCategoriaApplication.GetAsync(establecimientoCategoriaDTO.co_establecimiento_clase, establecimientoCategoriaDTO.co_establecimiento_subclase, establecimientoCategoriaDTO.co_establecimiento_categoria);

            if (response.IsSuccess)
            {
                if (response.Data.error_number == 0)
                {
                    return(Ok(response));
                }
                else
                {
                    return(NotFound(response));
                }
            }
            return(BadRequest(response));
        }
        public async Task <IActionResult> GetAllAsync([FromBody] EstablecimientoCategoriaDTO establecimientoCategoriaDTO)
        {
            var response = await _establecimientoCategoriaApplication.GetAllAsync(establecimientoCategoriaDTO);

            if (response.IsSuccess)
            {
                return(Ok(response));
            }

            return(BadRequest(response));
        }
        public IActionResult GetAll([FromBody] EstablecimientoCategoriaDTO establecimientoCategoriaDTO)
        {
            var response = _establecimientoCategoriaApplication.GetAll(establecimientoCategoriaDTO);

            if (response.IsSuccess)
            {
                return(Ok(response));
            }

            return(BadRequest(response));
        }
        private async Task <DialogTurnResult> SetEstablecimientoCategoria(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var choice = (FoundChoice)stepContext.Result;

            if (choice.Value == ExitOption)
            {
                await stepContext.Context.SendActivityAsync(MenuBot.Buttons(0, "En que te puedo ayudar?\n\n puedes utilizar los botones de la parte inferior."), cancellationToken);

                return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
            }

            stepContext.Values["co_establecimiento_subclase"] = CodigoList[choice.Index];
            stepContext.Values["no_establecimiento_subclase"] = choice.Value;

            EstablecimientoCategoriaDTO establecimientoCategoriaDTO = new EstablecimientoCategoriaDTO()
            {
                co_establecimiento_clase     = Convert.ToString(stepContext.Values["co_establecimiento_clase"]),
                co_establecimiento_subclase  = CodigoList[choice.Index],
                co_establecimiento_categoria = "",
                no_establecimiento_categoria = "",
                fl_inactivo = "0"
            };

            CodigoList.Clear();
            DescripcionList.Clear();

            EstablecimientoCategoriaClient establecimientoCategoriaClient = new EstablecimientoCategoriaClient();
            var result = establecimientoCategoriaClient.GetAllAsync(establecimientoCategoriaDTO);

            if (result.error_number == 0)
            {
                foreach (EstablecimientoCategoriaDTO item in result.Data)
                {
                    CodigoList.Add(item.co_establecimiento_categoria);
                    DescripcionList.Add(item.no_establecimiento_categoria);
                }
            }
            CodigoList.Add("0");
            DescripcionList.Add(ExitOption);

            var options = DescripcionList.ToList();

            var promptOptions = new PromptOptions
            {
                Prompt  = MessageFactory.Text("Por favor seleccione una **Categoria de Establecimiento**:"),
                Choices = ChoiceFactory.ToChoices(options),
                Style   = ListStyle.List
            };

            // Prompt the user for a choice.
            return(await stepContext.PromptAsync(nameof(ChoicePrompt), promptOptions, cancellationToken));
        }
        public ResponseQuery Delete(EstablecimientoCategoriaDTO establecimientoCategoriaDTO)
        {
            ResponseQuery responseQuery = new ResponseQuery();

            try
            {
                var establecimientoCategoria = _mapper.Map <EstablecimientoCategoria>(establecimientoCategoriaDTO);
                responseQuery = _establecimientoCategoriaDomain.Delete(establecimientoCategoria);
            }
            catch (Exception e)
            {
                responseQuery.error_number  = -1;
                responseQuery.error_message = e.Message;
            }
            return(responseQuery);
        }
        public async Task <ResponseQuery> UpdateAsync(EstablecimientoCategoriaDTO establecimientoCategoriaDTO)
        {
            ResponseQuery responseQuery = new ResponseQuery();

            try
            {
                var establecimientoCategoria = _mapper.Map <EstablecimientoCategoria>(establecimientoCategoriaDTO);
                responseQuery = await _establecimientoCategoriaDomain.UpdateAsync(establecimientoCategoria);
            }
            catch (Exception e)
            {
                responseQuery.error_number  = -1;
                responseQuery.error_message = e.Message;
            }
            return(responseQuery);
        }
        public IActionResult Update([FromBody] EstablecimientoCategoriaDTO establecimientoCategoriaDTO)
        {
            ResponseQuery responseQuery = new ResponseQuery();

            if (establecimientoCategoriaDTO == null)
            {
                responseQuery.error_number  = -1;
                responseQuery.error_message = "establecimientoCategoriaDTO no puede ser nulo.";
                return(BadRequest(responseQuery));
            }

            responseQuery = _establecimientoCategoriaApplication.Update(establecimientoCategoriaDTO);
            if (responseQuery.error_number == 0)
            {
                return(Ok(responseQuery));
            }

            return(BadRequest(responseQuery));
        }
        public Response <IEnumerable <EstablecimientoCategoriaDTO> > GetAll(EstablecimientoCategoriaDTO establecimientoCategoriaDTO)
        {
            var response = new Response <IEnumerable <EstablecimientoCategoriaDTO> >();

            try
            {
                var establecimientoCategoria  = _mapper.Map <EstablecimientoCategoria>(establecimientoCategoriaDTO);
                var establecimientoCategorias = _establecimientoCategoriaDomain.GetAll(establecimientoCategoria);
                response.Data = _mapper.Map <IEnumerable <EstablecimientoCategoriaDTO> >(establecimientoCategorias);
                if (response.Data != null)
                {
                    response.IsSuccess     = true;
                    response.error_message = "Consulta Exitosa!!!";
                }
            }
            catch (Exception e)
            {
                response.error_message = e.Message;
            }
            return(response);
        }
Ejemplo n.º 10
0
        public Response <IEnumerable <EstablecimientoCategoriaDTO> > GetAllAsync(EstablecimientoCategoriaDTO establecimientoCategoriaDTO)
        {
            var response = new Response <IEnumerable <EstablecimientoCategoriaDTO> >();

            var json = JsonConvert.SerializeObject(establecimientoCategoriaDTO);
            var data = new StringContent(json, Encoding.UTF8, "application/json");

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:4020/api/");
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + establecimientoCategoriaDTO.no_token);
                var responseTask = client.PostAsync("EstablecimientoCategoria/GetAllAsync", data);
                responseTask.Wait();

                var result   = responseTask.Result;
                var readTask = result.Content.ReadAsAsync <Response <IEnumerable <EstablecimientoCategoriaDTO> > >();
                readTask.Wait();
                response = readTask.Result;
            }
            return(response);
        }
Ejemplo n.º 11
0
        private async Task <DialogTurnResult> MostrarOpciones(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            List <string> EstablecimientoCategoriaList = new List <string>();

            EstablecimientoCategoriaDTO establecimientoCategoriaDTO = new EstablecimientoCategoriaDTO()
            {
                co_establecimiento_clase     = "",
                co_establecimiento_subclase  = "",
                co_establecimiento_categoria = "",
                no_establecimiento_categoria = "",
                fl_inactivo = "0"
            };

            EstablecimientoCategoriaClient establecimientoCategoriaClient = new EstablecimientoCategoriaClient();
            var result = establecimientoCategoriaClient.GetAllAsync(establecimientoCategoriaDTO);

            if (result.error_number == 0)
            {
                foreach (EstablecimientoCategoriaDTO item in result.Data)
                {
                    EstablecimientoCategoriaList.Add(item.no_establecimiento_categoria);
                }
            }

            var options = EstablecimientoCategoriaList.ToList();

            var promptOptions = new PromptOptions
            {
                Prompt  = MessageFactory.Text("Por favor seleccione una **Categoria de Establecimiento**:"),
                Choices = ChoiceFactory.ToChoices(options),
                Style   = ListStyle.List
            };

            // Prompt the user for a choice.
            return(await stepContext.PromptAsync(nameof(ChoicePrompt), promptOptions, cancellationToken));
        }