public async Task <IActionResult> Guardar(TarjetaViewModel entidad)
        {
            if (!ModelState.IsValid)
            {
                return(View("Editar", entidad));
            }
            if (entidad.Id == 0)
            {
                await _service.CreateAsync(entidad);
            }
            else
            {
                await _service.EditAsync(entidad);
            }

            /*  --------------------------- para mongodb registro bitacora */
            var bitacora = new BitacoraViewModel()
            {
                fecha   = DateTime.Now,
                Entidad = "Tarjeta",
                Accion  = "Crear/Editar",
                Detalle = entidad.Id.ToString()
            };
            await _bitacoraService.Create(bitacora);

            /*  --------------------------- para mongodb registro bitacora */

            return(RedirectToAction("Lista"));
        }
        public async Task <IActionResult> Editar(int id)
        {
            TarjetaViewModel view = null;

            if (id == 0)
            {
                view = new TarjetaViewModel()
                {
                    Expiracion = DateTime.Now.Date
                };
            }
            else
            {
                view = await _service.GetByIdAsync(id);
            }

            /*  --------------------------- para mongodb registro bitacora */
            var bitacora = new BitacoraViewModel()
            {
                fecha   = DateTime.Now,
                Entidad = "Tarjeta",
                Accion  = "Editar",
                Detalle = id.ToString()
            };
            await _bitacoraService.Create(bitacora);

            /*  --------------------------- para mongodb registro bitacora */


            return(View(view));
        }
Esempio n. 3
0
 public ActionResult AddTarjeta(TarjetaViewModel tar)
 {
     try
     {
         if (ModelState.IsValid)
         {
             RepoDapper TarRepo = new RepoDapper();
             tar.UserId = User.Identity.GetUserId();
             TarRepo.CrearTarjeta(tar);
             ViewBag.Message = "La tarjeta se agrego.";
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         ViewBag.Message = "La tarjeta no se agrego.";
         return(View());
     }
 }
Esempio n. 4
0
        //Falta probar que funcione bien desde aqui
        public void CrearTarjeta(TarjetaViewModel tar)
        {
            try
            {
                connection();
                con.Open();
                var parameters = new
                {
                    @nombre = tar.Nombre,
                    @numero = tar.Numero,
                    @fecha  = tar.Fecha,
                    @codigo = tar.Codigo,
                    @userid = tar.UserId,
                    @id     = tar.id
                };
                con.Execute("dbo.CrearTarjeta", parameters, commandType: CommandType.StoredProcedure);

                con.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
 public async Task EditAsync(TarjetaViewModel tarjeta)
 {
     await PutAsync($"tarjeta/{tarjeta.Id}", tarjeta).ConfigureAwait(false);
 }
Esempio n. 6
0
 public async Task CreateAsync(TarjetaViewModel tarjeta)
 {
     await PostAsync("tarjeta", tarjeta).ConfigureAwait(false);
 }