예제 #1
0
 public CategoriaGastoVIewModel DomainToViewModel(TbCpCategoriaGasto domain)
 {
     return(new CategoriaGastoVIewModel
     {
         Estado = (bool)domain.Estado,
         FechaCreacion = domain.FechaCreacion,
         Id = domain.Id,
         IdUsuario = domain.IdUsuario,
         Nombre = domain.Nombre,
         Tipo = (bool)domain.Tipo
     });
 }
예제 #2
0
        public IActionResult CrearEditarCategoriaGasto(CategoriaGastoVIewModel viewModel)
        {
            try
            {
                var existeCG = service.GetCGByNombre(viewModel.Nombre);
                var cg       = new TbCpCategoriaGasto();
                if (viewModel.Id != 0)
                {
                    if (existeCG != null && existeCG.Id != viewModel.Id)
                    {
                        return(Json(new { success = false, activo = existeCG.Estado }));
                    }

                    cg = map.Update(viewModel);
                }
                else
                {
                    if (existeCG != null)
                    {
                        return(Json(new { success = false, activo = existeCG.Estado }));
                    }
                    viewModel.Estado        = true;
                    viewModel.IdUsuario     = int.Parse(User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value);
                    viewModel.FechaCreacion = DateTime.Now;
                    cg = map.Create(viewModel);
                }


                return(Json(new { success = true }));
            }
            catch (Exception ex)
            {
                AltivaLog.Log.Insertar(ex.ToString(), "Error");

                throw;
            }
        }
 public TbCpCategoriaGasto Update(TbCpCategoriaGasto domain)
 {
     return(repository.Update(domain));
 }
 public TbCpCategoriaGasto Save(TbCpCategoriaGasto domain)
 {
     return(repository.Save(domain));
 }