Esempio n. 1
0
        public IActionResult MainRequestFormat(string pinEmployee,
                                               [FromServices] IRepository <PermissionType> _permissionTypeRepository,
                                               [FromServices] IOrganigramaModelFactory organigramaModelFactory,
                                               [FromServices] IRepository <EmployeeFormat> formatRepository,
                                               [FromServices] INomipaqEmployeeVacationModelFactory nomipaqEmployeeVacations)
        {
            var    data          = System.Convert.FromBase64String(pinEmployee);
            string base64Decoded = System.Text.ASCIIEncoding.ASCII.GetString(data);
            var    getEmployeeId = base64Decoded.Split('|');

            ViewBag.permissionType = _permissionTypeRepository.GetAll().Select(k => new SelectListItem()
            {
                Text = k.Description, Value = k.Id.ToString()
            });

            var employees = organigramaModelFactory.GetAllData().Employess;

            var info = organigramaModelFactory.GetEmployeeData(getEmployeeId[1].TrimStart(new Char[] { '0' }));

            FormatRequestModel model = new FormatRequestModel()
            {
                Employee          = $"{info.GeneralInfo.Id}",
                FulName           = $"{info.GeneralInfo.Id}-{info.GeneralInfo.FirstName} {info.GeneralInfo.LastName}",
                Picture           = info.GeneralInfo.Picture,
                JobTitle          = $"Puesto: {info.GeneralInfo.JobTitle}",
                Area              = $"Area: {info.Area}",
                JobCenter         = $"Centro de trabajo: {info.JobCenter}",
                EmployeeVacations = nomipaqEmployeeVacations.GetEmployeeVacations(getEmployeeId[1])
            };

            if (formatRepository.SearhItemsFor(y => y.EmployeeId.Equals(getEmployeeId[1].TrimStart(new Char[] { '0' }))).Any())
            {
                model.EmployeeFormats.AddRange(formatRepository.SearhItemsFor(y => y.EmployeeId.Equals(getEmployeeId[1].TrimStart(new Char[] { '0' }))).Select(r => new EmployeeFormatItem()
                {
                    Id                 = r.Id,
                    EmployeeId         = r.EmployeeId,
                    ApprovalDate       = r.ApprovalDate.HasValue ? r.ApprovalDate.Value.ToShortDateString() : "",
                    Comments           = r.Comments,
                    CreateDate         = r.CreateDate.ToShortDateString(),
                    EndDate            = r.EndDate.ToShortDateString(),
                    PermissionType     = _permissionTypeRepository.GetElement(r.PermissionType).Description,
                    StartDate          = $"({r.StartDate.ToShortDateString()})-({r.EndDate.ToShortDateString()})",
                    EmployeeSubstitute = employees.Where(k => k.Id.Equals(r.EmployeeSubstitute.TrimStart('0'))).FirstOrDefault().Name
                }));

                //var permissions = formatRepository.SearhItemsFor(y => y.EmployeeId.Equals("17") && )
            }

            return(View(model));
        }
Esempio n. 2
0
        public IActionResult MainRequestFormat(string idEmployee,
                                               [FromServices] IRepository <PermissionType> _permissionTypeRepository,
                                               [FromServices] IOrganigramaModelFactory organigramaModelFactory,
                                               [FromServices] IRepository <EmployeeFormat> formatRepository,
                                               [FromServices] INomipaqEmployeeVacationModelFactory nomipaqEmployeeVacations)
        {
            ViewBag.permissionType = _permissionTypeRepository.GetAll().Select(k => new SelectListItem()
            {
                Text = k.Description, Value = k.Id.ToString()
            });

            var employees = organigramaModelFactory.GetAllData().Employess;

            var info = organigramaModelFactory.GetEmployeeData(idEmployee);

            FormatRequestModel model = new FormatRequestModel()
            {
                Employee          = $"{info.GeneralInfo.Id.TrimStart(new Char[] { '0' })}",
                FulName           = $"{info.GeneralInfo.Id}-{info.GeneralInfo.FirstName} {info.GeneralInfo.LastName}",
                Picture           = info.GeneralInfo.Picture,
                JobTitle          = $"Puesto: {info.GeneralInfo.JobTitle}",
                Area              = $"Area: {info.Area}",
                JobCenter         = $"Centro de trabajo: {info.JobCenter}",
                EmployeeVacations = nomipaqEmployeeVacations.GetEmployeeVacations(int.Parse(idEmployee).ToString("00000"))
            };

            var formats = formatRepository.SearhItemsFor(y => y.EmployeeId.Equals(idEmployee));

            if (formats.Any())
            {
                model.EmployeeFormats.AddRange(formatRepository.SearhItemsFor(y => y.EmployeeId.Equals(idEmployee)).Select(r => new EmployeeFormatItem()
                {
                    Id                 = r.Id,
                    EmployeeId         = r.EmployeeId,
                    ApprovalDate       = r.ApprovalDate.HasValue ? r.ApprovalDate.Value.ToShortDateString() : "",
                    Comments           = r.Comments,
                    CreateDate         = r.CreateDate.ToShortDateString(),
                    EndDate            = r.EndDate.ToShortDateString(),
                    PermissionType     = _permissionTypeRepository.GetElement(r.PermissionType).Description,
                    StartDate          = $"({r.StartDate.ToShortDateString()})-({r.EndDate.ToShortDateString()})",
                    EmployeeSubstitute = employees.Where(k => k.Id.Equals(r.EmployeeSubstitute.TrimStart('0'))).FirstOrDefault().Name
                }));
            }

            model.TotalPermissionsApproved = model.EmployeeFormats.Where(h => !string.IsNullOrEmpty(h.ApprovalDate)).Count();

            return(View(model));
        }