private async Task SeedAdminUser(OmmDbContext context, UserManager <Employee> userManager)
        {
            if (!context.Users.Any(u => u.UserName == AdminUsername))
            {
                Employee admin = new Employee()
                {
                    UserName       = AdminUsername,
                    Email          = AdminEmail,
                    FirstName      = AdminFirstName,
                    LastName       = AdminLastName,
                    FullName       = AdminFullName,
                    AccessLevel    = AdminAccessLevel,
                    IsActive       = true,
                    ProfilePicture = AdminPicture
                };

                var result = userManager.CreateAsync(admin, AdminPassword).GetAwaiter().GetResult();

                if (result.Succeeded)
                {
                    await userManager.AddToRoleAsync(admin, AdminRole);

                    await userManager.AddClaimAsync(admin, new Claim(InfrastructureConstants.ACCESS_LEVEL_CLAIM, admin.AccessLevel.ToString()));
                }
            }
        }
Esempio n. 2
0
 public EmployeesService(UserManager <Employee> userManger, SignInManager <Employee> signInManager, OmmDbContext context, IDepartmentsService departmentsService, ISendGrid emailSender)
 {
     this.userManger         = userManger;
     this.signInManager      = signInManager;
     this.context            = context;
     this.departmentsService = departmentsService;
     this.emailSender        = emailSender;
 }
        private async Task SeedData(OmmDbContext context)
        {
            await context.AddRangeAsync(GetEmployeesDummyData());

            await context.AddRangeAsync(GetAssignmentsDummyData());

            await context.SaveChangesAsync();

            await context.AddRangeAsync(GetAssignmentsEmployeesDummyData());

            await context.SaveChangesAsync();
        }
Esempio n. 4
0
 public ProjectsService(OmmDbContext context, IReportsService reportsService, IStatusesService statusesService,
                        IEmployeesService employeesService, IProjectPositionsService projectPositionsService,
                        IEmployeesProjectsPositionsService employeesProjectsPositionsService, IAssignmentsService assignmentsService)
 {
     this.context                           = context;
     this.reportsService                    = reportsService;
     this.statusesService                   = statusesService;
     this.employeesService                  = employeesService;
     this.projectPositionsService           = projectPositionsService;
     this.employeesProjectsPositionsService = employeesProjectsPositionsService;
     this.assignmentsService                = assignmentsService;
 }
        private async Task SeedData(OmmDbContext context)
        {
            await context.AddRangeAsync(GetEmployeeDummyData());

            await context.AddRangeAsync(GetProjectDummyData());

            await context.AddRangeAsync(GetProjectPositionDummyData());

            await context.SaveChangesAsync();

            await context.AddRangeAsync(GetEmployeeProjectsPositionsDummyData());

            await context.SaveChangesAsync();
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            this.context = (OmmDbContext)validationContext.GetService(typeof(OmmDbContext));

            var propertyValues = this.context.Users.Select(u => u.GetType()
                                                           .GetProperty(this.property,
                                                                        BindingFlags.Instance |
                                                                        BindingFlags.Public |
                                                                        BindingFlags.IgnoreCase)
                                                           .GetValue(u, null))
                                 .Select(v => v.ToString())
                                 .ToList();

            if (propertyValues.Any(v => v == (string)value))
            {
                return(new ValidationResult(this.ErrorMessage));
            }

            return(ValidationResult.Success);
        }
 public ActivitiesService(OmmDbContext context)
 {
     this.context = context;
 }
Esempio n. 8
0
 public DepartmentsService(OmmDbContext context)
 {
     this.context = context;
 }
 public ProjectPositionSeeder(OmmDbContext context)
 {
     this.context = context;
 }
 public ReportsService(OmmDbContext context)
 {
     this.context = context;
 }
 public EmployeesProjectsPositionsService(OmmDbContext context)
 {
     this.context = context;
 }
Esempio n. 12
0
 public AssignmentsEmployeesService(OmmDbContext context)
 {
     this.context = context;
 }
Esempio n. 13
0
 public ProjectPositionsService(OmmDbContext context)
 {
     this.context = context;
 }
 public AssetTypeSeeder(OmmDbContext context)
 {
     this.context = context;
 }
Esempio n. 15
0
 public RolesSeeder(OmmDbContext context)
 {
     this.context = context;
 }
 public LeavingReasonsService(OmmDbContext context)
 {
     this.context = context;
 }
Esempio n. 17
0
 public StatusSeeder(OmmDbContext context)
 {
     this.context = context;
 }
Esempio n. 18
0
        private async Task SeedData(OmmDbContext context)
        {
            await context.AddRangeAsync(GetDummyData());

            await context.SaveChangesAsync();
        }
Esempio n. 19
0
 public LeavingReasonSeeder(OmmDbContext context)
 {
     this.context = context;
 }
Esempio n. 20
0
 public StatusesService(OmmDbContext context)
 {
     this.context = context;
 }
Esempio n. 21
0
 public CustomExceptionFilterAttribute(OmmDbContext context)
 {
     this.dbContext = context;
 }
 public AssetTypesService(OmmDbContext context)
 {
     this.context = context;
 }
 public AssignmentsService(OmmDbContext context, IStatusesService statusesService, IAssignmentsEmployeesService assignmentsEmployeesService)
 {
     this.context                     = context;
     this.statusesService             = statusesService;
     this.assignmentsEmployeesService = assignmentsEmployeesService;
 }
Esempio n. 24
0
 public DepartmentSeeder(OmmDbContext context)
 {
     this.context = context;
 }