Beispiel #1
0
        public async Task <IActionResult> Index(JobTitleFilterViewModel model = null)
        {
            if (model == null)
            {
                model = new JobTitleFilterViewModel();
            }

            var query = Uow.JobTitleTranslates.Where(t => t.CultureId == 1).OrderByDescending(e => e.Id)
                        .Select(t => new JobTitlesViewModel
            {
                Id           = t.Id,
                DepartmentId = t.Dictionary.DepartmentId,
                Name         = t.Text,
                IsDeleted    = t.Dictionary.IsDeleted
            });

            query = query.Filter(q => q.Id, WhereOperator.Equals, model.Id);
            query = query.Filter(q => q.Name, WhereOperator.Contains, model.Name);
            query = query.Filter(q => q.DepartmentId, WhereOperator.Equals, model.DepartmentId);


            model.PagedList = await query.ToPagedListAsync(model.Page, model.PageSize);

            var departments = _cache.GetDepartment(1);

            foreach (var row in model.PagedList)
            {
                row.Department = departments.TryGetValue(row.DepartmentId);
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_Grid", model));
            }

            Title = HrResources.JobTitles;
            BindControls(model);

            return(View(model));
        }
Beispiel #2
0
        public async Task <IActionResult> Index(int templateId, DocumentFilterViewModel model = null)
        {
            if (templateId <= 0)
            {
                return(NotFound());
            }


            if (model == null)
            {
                model = new DocumentFilterViewModel();
            }

            model.TemplateId = templateId;

            var query = from d in Uow.Documents.GetAll()
                        join e in Uow.Employees.GetAll() on d.CreatorId equals e.Id//todo user and employee mapping table and auto initialize
                        select new DocumentsViewModel
            {
                Id           = d.Id,
                DepartmentId = d.DepartmentId,
                JobTitleId   = d.JobTitleId,


                CreateDate = d.CreateDate,
                CreatorId  = d.CreatorId,
                IsDeleted  = d.IsDeleted,

                IsApproved = d.IsApproved
            };


            query = query.Filter(q => q.Id, WhereOperator.Equals, model.Id);

            if (!User.IsInAnyRole(Constants.Roles.Admin, Constants.Roles.IT, Constants.Roles.Administration))
            {
                query = query.Filter(q => q.CreatorId, WhereOperator.Equals, UserId);
            }


            model.PagedList = await query.ToPagedListAsync(model.Page, model.PageSize);

            var jobTitles   = _cache.GetJobTitle(null, 1);
            var departments = _cache.GetDepartment(1);
            var branches    = _cache.GetBranch(1);

            foreach (var row in model.PagedList)
            {
                if (row.JobTitleId != null)
                {
                    row.JobTitle = jobTitles.TryGetValue(row.JobTitleId.Value);
                }
                if (row.DepartmentId != null)
                {
                    row.Department = departments.TryGetValue(row.DepartmentId.Value);
                }

                //if (row.BranchId != null)
                //    row.Branch = branches.TryGetValue(row.BranchId.Value);
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_Grid", model));
            }

            ReturnUrl = Url.Action(nameof(Index), "Documents", new { templateId });
            Title     = await Uow.DocumentTemplates.Where(t => t.Id == templateId && !t.IsDeleted).Select(t => t.Name).SingleOrDefaultAsync();

            return(View(model));
        }
Beispiel #3
0
        public async Task <IActionResult> Index(EmployeeFilterViewModel model = null)
        {
            if (model == null)
            {
                model = new EmployeeFilterViewModel();
            }

            var query = Uow.Employees.GetAll().OrderByDescending(e => e.Id)
                        .Select(e => new EmployeesViewModel
            {
                Id           = e.Id,
                BranchId     = e.BranchId,
                JobTitleId   = e.JobTitleId,
                DepartmentId = e.DepartmentId,

                FullName       = e.Person.FullName,
                PersonalNumber = e.Person.PersonalNumber,
                BirthDate      = e.Person.BirthDate,
                GenderId       = e.Person.GenderId,
                IsDeleted      = e.Person.IsDeleted
            });

            query = query.Filter(q => q.Id, WhereOperator.Equals, model.Id);
            query = query.Filter(q => q.PersonalNumber, WhereOperator.Equals, model.PersonalNumber);
            query = query.Filter(q => q.FullName, WhereOperator.Contains, model.FullName);


            query = query.Filter(q => q.JobTitleId, WhereOperator.Equals, model.JobTitleId);
            query = query.Filter(q => q.BranchId, WhereOperator.Equals, model.BranchId);

            model.PagedList = await query.ToPagedListAsync(model.Page, model.PageSize);

            var jobTitles   = _cache.GetJobTitle(null, 1);
            var departments = _cache.GetDepartment(1);
            var branches    = _cache.GetBranch(1);

            foreach (var row in model.PagedList)
            {
                if (row.JobTitleId != null)
                {
                    row.JobTitle = jobTitles.TryGetValue(row.JobTitleId.Value);
                }
                if (row.DepartmentId != null)
                {
                    row.Department = departments.TryGetValue(row.DepartmentId.Value);
                }

                if (row.BranchId != null)
                {
                    row.Branch = branches.TryGetValue(row.BranchId.Value);
                }
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_Grid", model));
            }

            Title = HrResources.Employees;
            BindControls(model);


            return(View(model));
        }