Пример #1
0
        public async Task <IActionResult> OnGet(int Id, int categoriaId)
        {
            try
            {
                Categoria = await _categoriaRepository.GetByIdAsync(categoriaId);

                if (Categoria == null)
                {
                    _notifyService.Warning($"No se ha encontrado la categoria con el id {categoriaId}");
                    return(RedirectToPage("Index", new { area = "Categorias" }));
                }
                var negocio = await _repository.GetByIdAsync(Id);

                if (negocio == null)
                {
                    _notifyService.Warning($"No se ha encontrado el registro con el id {Id}");
                    return(RedirectToPage("Index", new { categoriaId = categoriaId }));
                }
                Negocio = negocio;

                return(Page());
            }
            catch (Exception ex)
            {
                _logger.LogWarning(ex.Message);
                return(RedirectToPage("Index", new { area = "Categorias" }));
            }
        }
Пример #2
0
        public async Task <IActionResult> OnGet(int id, int negocioId)
        {
            try
            {
                Negocio = await _negocioRepository.GetByIdAsync(negocioId);

                if (Negocio == null)
                {
                    _notifyService.Warning($"No se ha encontrado la zona con el id {negocioId}");
                    return(RedirectToPage("Index", new { area = "Negocios" }));
                }

                var producto = await _repository.GetByIdAsync(id);

                if (producto == null)
                {
                    _notifyService.Warning($"No se ha encontrado el registro con el id {id}");
                    return(RedirectToPage("Index", new { negocioId = negocioId }));
                }
                Producto = producto;

                return(Page());
            }
            catch (Exception ex)
            {
                _logger.LogWarning(ex.Message);
                return(RedirectToPage("Index", new { area = "Negocios" }));
            }
        }
        public async Task <IActionResult> OnGet(int Id)
        {
            Producto = await _repository.GetByIdAsync(Id);

            if (ModelState.IsValid)
            {
                return(Page());
            }
            return(NotFound());
        }
Пример #4
0
        public async Task <JsonResult> OnGetDetalles(int Id)
        {
            var paquete = await _repository.GetByIdAsync(Id);

            if (paquete == null)
            {
                _notyfService.Warning($"El paquete, con id {Id}, no ha sido encontrado.");
                return(new JsonResult(new { seleccionado = false }));
            }
            Paquete = paquete;
            return(new JsonResult(new
            {
                info = Paquete,
                Nombre_Fotografia = Paquete.Nombre_Fotografia()
            }));
        }
Пример #5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Usuario = await _repository.GetByIdAsync(id);

            if (Usuario == null)
            {
                return(NotFound());
            }

            return(Page());
        }
Пример #6
0
        public async Task <IActionResult> OnGet(int id)
        {
            try
            {
                var tipoNegocio = await _repository.GetByIdAsync(id);

                if (tipoNegocio == null)
                {
                    _notifyService.Warning($"No se ha encontrado el registro con el id {id}");
                    return(RedirectToPage("Index"));
                }
                TipoNegocio = tipoNegocio;
                return(Page());
            }
            catch (Exception ex)
            {
                _logger.LogWarning(ex.Message);
                throw;
            }
        }
Пример #7
0
        public async Task <IActionResult> OnGet(int id)
        {
            try
            {
                var categoria = await _repository.GetByIdAsync(id);

                if (categoria == null)
                {
                    _notifyService.Warning($"No se ha encontrado la categoria con el id {id}");
                    return(RedirectToPage("Index"));
                }
                Categoria = categoria;
                return(Page());
            }
            catch (Exception ex)
            {
                _logger.LogWarning(ex.Message);
                throw;
            }
        }
Пример #8
0
        public async Task <IActionResult> OnGet(int Id)
        {
            try
            {
                var paquete = await _repository.GetByIdAsync(Id);

                if (paquete == null)
                {
                    _notyfService.Warning($"El paquete, con id {Id}, no ha sido encontrado.");
                    return(RedirectToPage("Index"));
                }
                Paquete = paquete;
                return(Page());
            }
            catch (Exception ex)
            {
                _logger.LogWarning(ex.Message);
                throw;
            }
        }
Пример #9
0
        public async Task <IActionResult> OnGetAsync(int?Id, bool?saveChangesError = false)
        {
            if (Id == null)
            {
                return(NotFound());
            }

            Cliente = await _repository.GetByIdAsync(Id);


            if (Cliente == null)
            {
                return(NotFound());
            }

            if (saveChangesError.GetValueOrDefault())
            {
                ErrorMessage = String.Format("DELETE {Id} Failed. Try again", Id);
            }

            return(Page());
        }
Пример #10
0
        public async Task <JsonResult> OnGetSelect(int Id)
        {
            try
            {
                var paquete = await _repository.GetByIdAsync(Id);

                if (paquete == null)
                {
                    _notyfService.Warning($"El paquete, con id {Id}, no ha sido encontrado.");
                    return(new JsonResult(new { selected = false }));
                }
                Paquete = paquete;
                return(new JsonResult(new
                {
                    info = Paquete
                }));
            }
            catch (Exception ex)
            {
                _logger.LogWarning(ex.Message);
                throw;
            }
        }
        public async Task <JsonResult> OnPostEntregar(int Id)
        {
            var paquete = await _repository.GetByIdAsync(Id);

            if (paquete == null)
            {
                _notyfService.Warning($"El paquete, con id {Id}, no ha sido encontrado.");
                return(new JsonResult(new { aceptar = true }));
            }
            paquete.Estado_Paquete = "Envio finalizado";
            await _repository.UpdateAsync(paquete);

            return(new JsonResult(new { aceptar = false }));
        }
Пример #12
0
        public async Task <IActionResult> OnGetAsync(int?categoriaId, string searchString, int?currentPage, int?sizePage)
        {
            try
            {
                if (!categoriaId.HasValue)
                {
                    _notifyService.Warning($"Debe selecionar una categoria para ver sus negocios");
                    return(RedirectToPage("Index", new { area = "Categorias" }));
                }

                Categoria = await _categoriaRepository.GetByIdAsync(categoriaId.Value);

                if (Categoria == null)
                {
                    _notifyService.Warning($"No se ha encontrado una categoria con el id {categoriaId.Value}");
                    return(RedirectToPage("Index", new { area = "Categorias" }));
                }

                var totalItems = await _repository.CountAsync(new NegocioSpec(
                                                                  new NegocioFilter
                {
                    CategoriaId = categoriaId.Value,
                    Nombre = searchString,
                    LoadChildren = false,
                    IsPagingEnabled = true
                }));

                UIPagination = new UIPaginationModel(currentPage, searchString, sizePage, totalItems);
                Negocios     = await _repository.ListAsync(new NegocioSpec(
                                                               new NegocioFilter
                {
                    IsPagingEnabled = true,
                    Nombre = UIPagination.SearchString,
                    CategoriaId = categoriaId.Value,
                    PageSize = UIPagination.GetPageSize,
                    Page = UIPagination.GetCurrentPage,
                    LoadChildren = true
                })
                                                           );

                return(Page());
            }
            catch (Exception ex)
            {
                _logger.LogWarning(ex.Message);
                return(RedirectToPage("Index", new { area = "Categorias" }));
            }
        }
Пример #13
0
        public NegocioValidator(MyRepository <Negocio> negocioRepository)
        {
            _negocioRepository = negocioRepository;

            RuleFor(x => x.Id).NotNull();
            RuleFor(x => x.NegocioId).NotNull().WithMessage("Negocio es requerido.");
            RuleFor(x => x.NegocioId).MustAsync(async(id, cancellation) =>
            {
                return(await _negocioRepository.GetByIdAsync(id) == null ? false : true);
            }).WithMessage("Debe ingresar un negocio válido");

            RuleFor(x => x.Nombre).NotNull().WithMessage("Nombre es requerido.");
            RuleFor(x => x.Nombre).NotEmpty().WithMessage("Nombre es requerido.");
            RuleFor(x => x.Estado).NotNull().WithMessage("Estado es requerido.");
            RuleFor(x => x.Precio).NotNull().WithMessage("Precio es requerida.");
            RuleFor(x => x.Nombre).Length(3, 50).WithMessage("Nombre debe tener entre 3 y 50 caracteres.");
        }
Пример #14
0
        public NegocioValidator(MyRepository <Categoria> categoriaRepository)
        {
            _categoriaRepository = categoriaRepository;

            RuleFor(x => x.Id).NotNull();
            RuleFor(x => x.CategoriaId).NotNull().WithMessage("Categoria es requerida.");
            RuleFor(x => x.CategoriaId).MustAsync(async(id, cancellation) =>
            {
                return(await _categoriaRepository.GetByIdAsync(id) == null ? false : true);
            }).WithMessage("Debe ingresar una categoria válida");

            RuleFor(x => x.Nombre).NotNull().WithMessage("Nombre es requerido.");
            RuleFor(x => x.Nombre).NotEmpty().WithMessage("Nombre es requerido.");
            RuleFor(x => x.Activo).NotNull().WithMessage("Nombre es requerido.");
            RuleFor(x => x.Direccion).NotNull().WithMessage("Dirección es requerida.");
            RuleFor(x => x.Telefono).NotNull().WithMessage("Teléfono es requerido.");
            RuleFor(x => x.Email).NotNull().WithMessage("Email es requerido.");
            RuleFor(x => x.Nombre).Length(3, 50).WithMessage("Nombre debe tener entre 3 y 50 caracteres.");
        }
Пример #15
0
        public async Task <JsonResult> OnPostDelete(int id)
        {
            try
            {
                var tipoNegocio = await _repository.GetByIdAsync(id);

                if (tipoNegocio == null)
                {
                    _notifyService.Warning($"No se ha encontrado el registro con el id {id}");
                    return(new JsonResult(new { deleted = false }));
                }

                await _repository.DeleteAsync(tipoNegocio);

                return(new JsonResult(new { deleted = true }));
            }
            catch (Exception ex)
            {
                _logger.LogWarning(ex.Message);
                _notifyService.Error("Ocurrio un error en el servidor, intente nuevamente");
                return(new JsonResult(new { deleted = false }));
            }
        }
Пример #16
0
 /// <inheritdoc/>
 public Task <T> GetByIdAsync(int id, CancellationToken cancellationToken = default)
 {
     return(_sourceRepository.GetByIdAsync(id, cancellationToken));
 }