Example #1
0
        private void InitializeServices()
        {
            RootWorkItem.Services.AddNew <FormService, IFormService>();
            var syncService = new DataSyncService("192.168.0.101:3000");

            RootWorkItem.Services.Add(syncService);
        }
Example #2
0
        public async Task <User> FindByNameAsync(string userName, string sessionId)
        {
            if (String.IsNullOrEmpty(userName))
            {
                return(null);
            }

            await DataSyncService.SynchronizeDataWithSmg(sessionId);

            return(await FindByNameAsync(userName));
        }
Example #3
0
        public async Task <User> FindByNameAsync(string userName, EmployeesAccessRules?accessRule = null, bool skipSync = false)
        {
            accessRule = accessRule ?? (EmployeesAccessRules?)ApplicationSettingsService.Instance.Settings.EmployeesAccessRule;

            if (!skipSync)
            {
                await DataSyncService.SynchronizeDataWithSmg();
            }

            IQueryable <User> users;

            if ((int)accessRule.Value != ApplicationSettingsService.Instance.Settings.EmployeesAccessRule)
            {
                if (accessRule.Value == EmployeesAccessRules.AllEmployees)
                {
                    users = unitOfWork.UsersRepository.Query();
                }
                else
                {
                    var departmentId = SessionHelper.GetUserDepartmentIdFromOwinContext();
                    if (departmentId != Guid.Empty)
                    {
                        users = unitOfWork.UsersRepository.QueryInDepartment(departmentId);
                    }
                    else
                    {
                        throw new ApplicationException("User's department not found");
                    }
                }
            }
            else
            {
                users = Users;
            }

            var lowerUserName = userName.ToLower();

            return(await users.FirstOrDefaultAsync(x => x.UserName.ToLower() == lowerUserName));
        }