コード例 #1
0
        private async Task Search()
        {
            if (!string.IsNullOrEmpty(this.Serie))
            {
                this.Item        = null;
                this.ItemStatus  = null;
                this.Promos      = null;
                this.Corridas    = null;
                this.Existencias = null;

                var ser = _common.PrepareSerie(this.Serie);
                var res = await _proxy.ScanProductoAsync(ser, this.Sucursal.Clave);

                if (res != null)
                {
                    this.Serie      = null;
                    this.Item       = res.Producto;
                    this.ItemStatus = res.Status;

                    if (res.Producto.Id.HasValue)
                    {
                        this.Corridas = await _proxy.GetPreciosAsync(res.Producto.Id.Value);
                    }
                }
            }
            else if (!string.IsNullOrEmpty(this.Marca) && !string.IsNullOrEmpty(this.Modelo))
            {
                this.Item        = null;
                this.ItemStatus  = null;
                this.Promos      = null;
                this.Corridas    = null;
                this.Existencias = null;

                //var model = String.Format("{0,7}", this.Modelo);
                var model = _common.PrepareModelo(this.Modelo);

                var res = _proxy.FindProducto(this.Marca, model, this.Sucursal.Clave);
                if (res != null)
                {
                    this.Marca  = null;
                    this.Modelo = null;

                    this.Item = res;

                    if (res.Id.HasValue)
                    {
                        this.Corridas = await _proxy.GetPreciosAsync(res.Id.Value);
                    }
                }
            }
            else
            {
                return;
            }

            if (this.Item != null)
            {
                var request = new Common.Entities.CheckPromocionesRequest
                {
                    Sucursal  = this.Sucursal.Clave,
                    Productos = new Common.Entities.SerieFormasPago[]
                    {
                        new Common.Entities.SerieFormasPago
                        {
                            ArticuloId = this.Item.Id,
                            Serie      = this.Item.Serie,
                            //FormasPago = new Common.Constants.FormaPago[]
                            //{
                            //    Common.Constants.FormaPago.EF
                            //}
                        }
                    }
                };
                this.Promos = await _proxy.GetPromocionesAsync(request);
            }
        }