コード例 #1
0
        public IActionResult Modificar(StockViewModel p_stockArticuloVM)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View("error"));
                }
                else
                {
                    StockArticuloDTO stockArticuloDTO = this._mapper.Map <StockArticuloDTO>(p_stockArticuloVM);
                    int result = this._stockArticuloService.ModificarStockArticulo(stockArticuloDTO);

                    ViewBag.result = "Accion realizada con exito.";
                    List <StockViewModel> listStockViewModelo = this._stockArticuloService.getStockArticulos()
                                                                .Select(x => this._mapper.Map <StockViewModel>(x))
                                                                .ToList();

                    return(View("index", listStockViewModelo));
                }
            }
            catch (Exception ex)
            {
                ViewBag.error          = ex.InnerException.Message;
                ViewData["accionCRUD"] = AccionesCRUD.MODIFICAR;
                return(View("form", p_stockArticuloVM));
            }
        }
コード例 #2
0
        public int AgregarStockArticulo(StockArticuloDTO p_stockArticuloDTO)
        {
            int result = this._stockArticuloRepository.Add(new StockArticulo
            {
                Articulo = this._articuloRepository.GetById(p_stockArticuloDTO.ArticuloId),
                Cantidad = p_stockArticuloDTO.Cantidad,
            });

            return(result);
        }
コード例 #3
0
        public int ModificarStockArticulo(StockArticuloDTO p_stockArticuloDTO)
        {
            StockArticulo objEntity = this._stockArticuloRepository.GetById(p_stockArticuloDTO.Id);

            objEntity.Articulo = this._articuloRepository.GetById(p_stockArticuloDTO.ArticuloId);
            objEntity.Cantidad = p_stockArticuloDTO.Cantidad;

            int result = this._stockArticuloRepository.Update(objEntity);

            return(result);
        }
コード例 #4
0
        public StockArticuloDTO getStockArticulo(int p_id)
        {
            StockArticulo    objEntity = this._stockArticuloRepository.GetById(p_id);
            StockArticuloDTO objResult = new StockArticuloDTO
            {
                Id         = objEntity.Id,
                ArticuloId = objEntity.Articulo.Id,

                ArticuloDescripcion = $"{objEntity.Articulo.CodigoBarras} - " +
                                      $"{objEntity.Articulo.Modelo.Descripcion} - " +
                                      $"{objEntity.Articulo.Color.Descripcion} - " +
                                      $"{objEntity.Articulo.Marca.Descripcion} - " +
                                      $"{objEntity.Articulo.Categoria.Descripcion}",

                Cantidad = objEntity.Cantidad
            };

            return(objResult);
        }
コード例 #5
0
        public IActionResult Form([FromQuery] AccionesCRUD accionCRUD, int?Id)
        {
            try
            {
                if (accionCRUD.Equals(AccionesCRUD.AGREGAR) || accionCRUD.Equals(AccionesCRUD.MODIFICAR))
                {
                    ViewData["accionCRUD"] = accionCRUD;

                    StockViewModel stockArticuloViewModel = new StockViewModel();


                    /*
                     * obtiene los articulos sin asignacion de stock
                     */
                    List <SelectListItem> articulosSinAsignacionStock = this._stockArticuloService.ObtenerArticulosSinAsignacionStock()
                                                                        .Select(x => new SelectListItem
                    {
                        Value = x.Id.ToString(),
                        Text  = $"{x.ModeloDescripcion} - {x.ColorDescripcion} - {x.MarcaDescripcion} - {x.CategoriaDescripcion}"
                    }).ToList();


                    if (accionCRUD.Equals(AccionesCRUD.AGREGAR))
                    {
                        stockArticuloViewModel.Articulos = articulosSinAsignacionStock;
                        return(View(stockArticuloViewModel));
                    }

                    if (accionCRUD.Equals(AccionesCRUD.MODIFICAR))
                    {
                        StockArticuloDTO stockArticuloDTO = this._stockArticuloService.getStockArticulo((int)Id);
                        stockArticuloViewModel = this._mapper.Map <StockViewModel>(stockArticuloDTO);
                        return(View(stockArticuloViewModel));
                    }
                }
                throw new Exception("Ocurrio un error inesperado.");
            }
            catch (Exception ex)
            {
                ViewBag.error = ex.Message;
                return(View());
            }
        }
コード例 #6
0
 public IActionResult Detalle(int Id)
 {
     try
     {
         StockArticuloDTO stockArticuloDTO = this._stockArticuloService.getStockArticulo((int)Id);
         if (stockArticuloDTO != null)
         {
             StockViewModel stockViewModel = this._mapper.Map <StockArticuloDTO, StockViewModel>(stockArticuloDTO);
             return(View(stockViewModel));
         }
         else
         {
             ViewBag.error = "Ocurrio un erro al intentar obtener el registro solicitado.";
             return(View("index")); //deberia mostrar un msg de notificacion
         }
     }
     catch (Exception ex)
     {
         ViewBag.error = ex.Message;
         return(View("index"));
     }
 }