private async Task Scan() { var ser = _common.PrepareSerie(this.Search); if (this.Productos.Any()) { var item = this.Productos.Where(i => i.Producto.Serie == ser).SingleOrDefault(); if (item != null) { this.Search = null; item.Scanned = true; } else { this.ErrorMessage = Resources.Resource.Cancelacion_NoEncontrado; } } else { var item = await _proxy.ScanProductoDevolucionAsync(ser, cancelacion : true); if (item != null && item.Success) { this.Search = null; var res = await _proxy.FindSaleAsync(item.Producto.Sucursal, item.Producto.Folio); if (res != null) { this.Devolucion = new Models.SucursalFolio { Folio = res.Folio, Sucursal = res.Sucursal }; foreach (var p in res.Productos) { var can = new Models.CancelProducto { Producto = p }; if (can.Producto.Serie == ser) { can.Scanned = true; } can.PropertyChanged += (s, e) => { this.CancelCommand.RaiseCanExecuteChanged(); }; this.Productos.Add(can); } } } else { if (item == null) { this.ErrorMessage = "Artículo no encontrado"; } else { this.ErrorMessage = "Artículo no valido"; } //this.ErrorMessage = Resources.Resource.Cancelacion_NoValido; } } }