Пример #1
0
        public async Task <ActionResult> SaveTransfer(ProductTransferModels model)
        {
            ProductTransfer productTransfer = new ProductTransfer()
            {
                warehouseOrigin  = model.warehouseOrigin,
                warehouseDestiny = model.warehouseDestiny,
                observation      = model.observation,
                status           = "0",
                products         = model.products,
                dateCreated      = DateTime.Now.ToString("dd/MM/yyyy hh:mm")
            };

            try
            {
                _productTransferServices = new ProductTransferServices();
                var result = await _productTransferServices.SaveProductTransfer(productTransfer);

                if (result == null)
                {
                    ModelState.AddModelError("", "Error al buscar el producto");
                }
            }
            catch (System.Exception)
            {
                return(null);
            }

            return(RedirectToAction("getAll"));
        }
        private async void validateTransfer()
        {
            if (ProductTransferCollection.Count == 0)
            {
                await App.Current.MainPage.DisplayAlert("TSHIRT", "Debe ingresar uno o más productos a transferir", "OK");
            }
            else
            {
                var answer = await App.Current.MainPage.DisplayAlert("TSHIRT", "Desea Guardar la solicitud?", "SI", "NO");

                if (answer)
                {
                    int pendiente = (int)ProductTransferEstatus.Pendiente;

                    ProductTransfer productsTransfer = new ProductTransfer()
                    {
                        warehouseOrigin  = _warehouseOriginSelect,
                        warehouseDestiny = _warehouseDestinySelect,
                        products         = ProductTransferCollection.ToList(),
                        dateCreated      = DateTime.Now.ToString("dd/MM/yyyy hh:mm"),
                        status           = pendiente.ToString(),
                        observation      = Observation
                    };

                    var result = await _productTransferServices.SaveProductTransfer(productsTransfer);

                    if (result != null)
                    {
                        string id = string.Concat("00", result.Id.ToString());
                        id = id.Substring(id.Length - 3);
                        await Application.Current.MainPage.Navigation.PushAsync(new Result(id));
                    }
                    else
                    {
                        await App.Current.MainPage.DisplayAlert("TSHIRT", "Error al registrar la solicitud", "OK");
                    }
                }
            }
        }