Ejemplo n.º 1
0
        /// <summary>
        /// Employees management
        /// </summary>
        /// <returns></returns>
        public ActionResult EmployeesManagement(int active = -1)
        {
            EmployeesController employees = new EmployeesController();

            ViewBag.ActiveFlag = (active == 1 ? true : false);

            return(View((active == -1 ? employees.Get() : employees.Get().Where(item => item.Active == (active == 1 ? true : false)))));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get Employees
        /// </summary>
        /// <returns></returns>
        public JsonResult Employees(string id = "")
        {
            EmployeesController employees = new EmployeesController();

            MEmployeesEnt employee = employees.Get(int.Parse(id)).MapTo <MEmployees, MEmployeesEnt>();

            return(Json(employee, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get employees
        /// </summary>
        /// <returns></returns>
        public JsonResult GetEmployeeNames(int id, int active)
        {
            EmployeesController employees = new EmployeesController();

            List <MEmployees> listEmployees = (active == -1 ? employees.Get() : employees.Get().Where(item => item.Active == (active == 1 ? true : false)).ToList());

            if (id != 0)
            {
                listEmployees = listEmployees.Where(item => item.EmployeeID == id).ToList();
            }

            List <MCatalogs> catalog = new List <MCatalogs>();

            listEmployees.ForEach(item => catalog.Add(new MCatalogs()
            {
                ID = item.EmployeeID, Name = string.Format("{0} {1}", item.Name, item.LastNames)
            }));

            return(Json(catalog, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Generate Monthly PayRoll
        /// </summary>
        /// <param name="generate">Flag to generate</param>
        /// <param name="year">Year</param>
        /// <param name="month">Month</param>
        /// <returns></returns>
        public ActionResult GenerateMonthlyPayRoll(bool generate = false, int year = 0, int month = 0, int action = -1)
        {
            EmployeesController employees = new EmployeesController();

            List <MEmployees> listEmployees = null;

            List <MPayRoll> listPayRolls = null;

            ViewBag.Year  = year;
            ViewBag.Month = month;

            if (generate)
            {
                //Get days by month
                DateTime dateFirst = new DateTime(year, month, 1);
                DateTime dateLast  = new DateTime(year, month + 1, 1).AddDays(-1);

                //Get employee
                employees     = new EmployeesController();
                listEmployees = employees.Get().Where(item => item.Active == true).ToList();

                //Generates Payroll
                string            msgResult         = string.Empty;
                PayRollController payRollController = new PayRollController();
                foreach (MEmployees employee in listEmployees)
                {
                    if (
                        payRollController.Get().Where
                        (
                            item => item.PayRollInfoID == employee.PayRollInfo_.PayRollInfoID &&
                            ((DateTime)item.PayRollDate).Year == year &&
                            ((DateTime)item.PayRollDate).Month == month
                        ).Count() == 0)
                    {
                        //Payroll
                        payRollController.Post(dateFirst, dateLast, dateLast, employee.PayRollInfo_.PayRollInfoID);
                        msgResult += string.Format("- <span style='color: rgba(0, 0, 0, 0.55); font-weight: 600;'>Employee [ {0} {1} ] - PayRoll generated successfully</span> <br>", employee.Name, employee.LastNames);
                    }
                    else
                    {
                        msgResult += string.Format("- <span style='color: rgba(0, 0, 0, 0.55); font-weight: 600;'>Employee [ {0} {1} ] - PayRoll was already generated</span> <br>", employee.Name, employee.LastNames);
                    }
                }

                return(Json(msgResult, JsonRequestBehavior.AllowGet));
            }
            else
            {
                listPayRolls = new PayRollController().Get().Where(item => ((DateTime)item.PayRollDate).Year == year && ((DateTime)item.PayRollDate).Month == month && ((bool)item.Employee.Active) == true).ToList();

                return(View(listPayRolls));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Check if email exists
        /// </summary>
        /// <returns></returns>
        public JsonResult EmailExists(string email = "")
        {
            EmployeesController employees = new EmployeesController();

            int emailCount = 0;

            if (email == "")
            {
                return(Json((emailCount), JsonRequestBehavior.AllowGet));
            }

            emailCount = employees.Get().Where(item => item.Email.Trim() == email.Trim()).ToList().Count();

            return(Json((emailCount), JsonRequestBehavior.AllowGet));
        }