Пример #1
0
        public async Task <IActionResult> OnGet(Guid documentTypeId)
        {
            try
            {
                if (_getAccountDataService.IsSystemAdmin())
                {
                    selectedDocumentType = await db.DocumentType.FirstOrDefaultAsync(dt => dt.Id.Equals(documentTypeId));

                    DocumentTitles = await db.DocumentTitle
                                     .Where(dt => dt.DocumentTypeId.Equals(documentTypeId))
                                     .ToListAsync();

                    return(Page());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error while getting page of showing list of document titles");
                return(NotFound());
            }
        }
Пример #2
0
        public async Task <IActionResult> OnGetAsync(string userid)
        {
            try
            {
                // получаем пользователя
                User user = await _userManager.FindByIdAsync(userid);

                IsSystemAdmin = _getAccountDataService.IsSystemAdmin();

                if (user != null && IsSystemAdmin)
                {
                    // получем список ролей пользователя
                    var userSystemRoles = await _userManager.GetRolesAsync(user);

                    var allSystemRoles = _roleManager.Roles.ToList();
                    EditUserRolesViewModel = new EditUserRolesViewModel
                    {
                        UserId          = user.Id.ToString(),
                        UserEmail       = user.Email,
                        UserSystemRoles = userSystemRoles,
                        AllSystemRoles  = allSystemRoles
                    };
                    return(Page());
                }
                return(NotFound());
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error while loading EditUserRoles page");
                return(NotFound());
            }
        }
Пример #3
0
        public async Task <IActionResult> OnGetAsync(Guid yearId)
        {
            try
            {
                selectedReportingYearId = yearId;

                if (_getAccountDataService.IsSystemAdmin())
                {
                    Departments = await db.Department.ToListAsync();
                }
                else
                {
                    Departments = await _getAccountDataService.SelectDepartmentsWhereUserHaveAnyRole(db.Department).ToListAsync();
                }

                var CurrentBreadCrumb = await _breadcrumbService.GetReportingYearBreadCrumbNodeAsync(yearId);

                ViewData["BreadcrumbNode"] = CurrentBreadCrumb;
                ViewData["Title"]          = CurrentBreadCrumb.Title;

                return(Page());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error while getting year page");
                return(NotFound());
            }
        }
Пример #4
0
        public async Task <IActionResult> OnGetAsync()
        {
            try
            {
                currentUser = await _userManager.GetUserAsync(HttpContext.User);

                IsSystemAdmin = _getAccountDataService.IsSystemAdmin();

                if (currentUser != null)
                {
                    allUserDepartmentRoles = await db.UserRoleDepartment
                                             .Where(urd => urd.UserId.Equals(currentUser.Id))
                                             .Include(urd => urd.Role)
                                             .GroupBy(urd => urd.Department.Name)
                                             .ToListAsync();

                    return(Page());
                }
                return(Page());
            }catch (Exception e)
            {
                _logger.LogError(e, "Error while getting user info");
                return(NotFound());
            }
        }
Пример #5
0
        public async Task <IActionResult> OnGetAsync(string userid)
        {
            try
            {
                IsSystemAdmin = _getAccountDataService.IsSystemAdmin();

                // получаем пользователя
                User user = await _userManager.FindByIdAsync(userid);

                if (user != null && (await _getAccountDataService.UserIsAdminOnAnyDepartment() || IsSystemAdmin))
                {
                    List <Role> allRoles = await db.Role.ToListAsync();

                    allUserDepartmentRoles = await db.UserRoleDepartment
                                             .Where(urd => urd.UserId.Equals(user.Id))
                                             .Include(udr => udr.Role)
                                             .GroupBy(urd => urd.Department.Name)
                                             .ToListAsync();

                    List <Department> allDepartments = db.Department.ToList();
                    EditUserDepartmentRolesViewModel = new EditUserDepartmentRolesViewModel
                    {
                        UserId              = user.Id.ToString(),
                        UserEmail           = user.Email,
                        UserDepartmentRoles = new List <UserDepartmentRole>()
                        {
                        },
                        AllRoles       = allRoles,
                        AllDepartments = allDepartments
                    };
                    return(Page());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error while getting page EditUserDepartmentRoles");
                return(NotFound());
            }
        }
Пример #6
0
 public IActionResult OnGet()
 {
     try
     {
         if (_getAccountDataService.IsSystemAdmin())
         {
             return(Page());
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception e)
     {
         _logger.LogError(e, "Error while getting page of Creating document type");
         return(NotFound());
     }
 }
Пример #7
0
        public async Task <IActionResult> OnGet()
        {
            try
            {
                if (_getAccountDataService.IsSystemAdmin())
                {
                    DocumentTypes = await db.DocumentType.ToListAsync();

                    return(Page());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error while getting page of showing list of document types");
                return(NotFound());
            }
        }
Пример #8
0
        public async Task <IActionResult> OnGet()
        {
            try
            {
                if (_getAccountDataService.IsSystemAdmin())
                {
                    ReportingYears = await db.ReportingYear.ToListAsync();

                    return(Page());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error while getting page of showing list of reporing years");
                return(NotFound());
            }
        }
Пример #9
0
        public async Task <IActionResult> OnGet()
        {
            try
            {
                if (_getAccountDataService.IsSystemAdmin())
                {
                    Departments = await db.Department.ToListAsync <Department>();

                    return(Page());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error while getting page DepartmentList");
                return(NotFound());
            }
        }
Пример #10
0
        public async Task <IActionResult> OnGetAsync(Guid titleId)
        {
            try
            {
                if (_getAccountDataService.IsSystemAdmin())
                {
                    selectedDocumentTitle = await db.DocumentTitle
                                            .FirstOrDefaultAsync(dt => dt.Id == titleId);

                    return(Page());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error while getting page of Editing document title");
                return(NotFound());
            }
        }
Пример #11
0
        public async Task <IActionResult> OnGetAsync()
        {
            try
            {
                if (_getAccountDataService.IsSystemAdmin())
                {
                    documentTypes = await db.DocumentType
                                    .Include(dt => dt.DocumentTitles)
                                    .ToListAsync();

                    return(Page());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error while getting page of Creating year");
                return(NotFound());
            }
        }
Пример #12
0
        public async Task <IActionResult> OnGet()
        {
            try
            {
                IsSystemAdmin = _getAccountDataService.IsSystemAdmin();

                if (IsSystemAdmin || await _getAccountDataService.UserIsAdminOnAnyDepartment())
                {
                    Users = await _userManager.Users.ToListAsync();

                    return(Page());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error while getting page UserDepartmentList");
                return(NotFound());
            }
        }