Esempio n. 1
0
        public async Task <IActionResult> AddComprobante(ElementoComprobanteViewModel model)
        {
            if (ModelState.IsValid)
            {
                var path = string.Empty;

                if (model.ComprobanteFile != null)
                {
                    path = await _comprobanteHelper.UploadComprobanteAsync(model.ComprobanteFile);
                }

                var elementoComprobante = new ElementoComprobante
                {
                    ComprobanteUrl    = path,
                    Elemento          = await _dataContext.Elementos.FindAsync(model.ElementoComprobanteId),
                    ComprobanteNombre = model.ComprobanteFile.FileName
                };

                _dataContext.ElementoComprobantes.Add(elementoComprobante);
                await _dataContext.SaveChangesAsync();

                //return RedirectToAction($"{nameof(Details)}/{model.ElementoImageId}");
                return(RedirectToAction("Details", "Elementos", new { @id = elementoComprobante.Elemento.ElementoID }));
            }

            return(View(model));
        }
Esempio n. 2
0
        public async Task <IActionResult> AddComprobante(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var elemento = await _dataContext.Elementos.FindAsync(id.Value);

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

            var model = new ElementoComprobanteViewModel
            {
                ElementoComprobanteId = elemento.ElementoID
            };

            return(View(model));
        }