Ejemplo n.º 1
0
        public static bool AgregarHaber(RequestCreateHaber DataHaber, remuneracionesContext db)
        {
            bool Result = false;

            try
            {
                if (DataHaber != null)
                {
                    int CategoriaHaber = Convert.ToInt32(DataHaber.TipoHaber);
                    var ObjHaber       = new ColeccionHaberes()
                    {
                        Categoria_id = (CategoriaHaberes)CategoriaHaber,
                        Nombre       = DataHaber.NombreHaber,
                        ValorCalculo = Convert.ToDecimal(DataHaber.MontoHaber),
                        EmpresaId    = 1
                    };

                    db.ColeccionHaberes.Add(ObjHaber);
                    db.SaveChanges();
                    Result = true;
                }
            }
            catch (Exception)
            {
                Result = false;
            }


            return(Result);
        }
Ejemplo n.º 2
0
        public static Tuple <List <ColeccionHaberes>, List <ColeccionDescuentos> > ObtenerHyDEmpleado(int EmpleadoId, remuneracionesContext db)
        {
            List <ColeccionHaberes>    EmpH = new List <ColeccionHaberes>();
            List <ColeccionDescuentos> EmpD = new List <ColeccionDescuentos>();

            try
            {
                List <int> EmpHaberes    = db.HaberesYDescuentosEmpleado.Where(x => x.EmpleadoId == EmpleadoId && x.TipoHoD == TipoHaberODescuento.HABER).Select(x => x.HaberOdescuentoId).ToList();
                List <int> EmpDescuentos = db.HaberesYDescuentosEmpleado.Where(x => x.EmpleadoId == EmpleadoId && x.TipoHoD == TipoHaberODescuento.DESCUENTO).Select(x => x.HaberOdescuentoId).ToList();

                foreach (int ItemIdHaber in EmpHaberes)
                {
                    var Haber = new ColeccionHaberes();
                    Haber = db.ColeccionHaberes.SingleOrDefault(x => x.Id == ItemIdHaber);
                    if (Haber != null)
                    {
                        EmpH.Add(Haber);
                    }
                }
                foreach (int ItemIdDescuento in EmpDescuentos)
                {
                    var Descuento = new ColeccionDescuentos();
                    Descuento = db.ColeccionDescuentos.SingleOrDefault(x => x.Id == ItemIdDescuento);
                    if (Descuento != null)
                    {
                        EmpD.Add(Descuento);
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }



            return(Tuple.Create(EmpH, EmpD));
        }