Exemple #1
0
 public static async Task Build <T>(this T entity, TimeKeeperContext context)
 {
     if (typeof(T) == typeof(Member))
     {
         await BuildRelations(entity as Member, context);
     }
     if (typeof(T) == typeof(Project))
     {
         await BuildRelations(entity as Project, context);
     }
     if (typeof(T) == typeof(Day))
     {
         await BuildRelations(entity as Day, context);
     }
     if (typeof(T) == typeof(JobDetail))
     {
         await BuildRelations(entity as JobDetail, context);
     }
     if (typeof(T) == typeof(Customer))
     {
         await BuildRelations(entity as Customer, context);
     }
     if (typeof(T) == typeof(Employee))
     {
         await BuildRelations(entity as Employee, context);
     }
     if (typeof(T) == typeof(User))
     {
         BuildPassword(entity as User);
     }
 }
Exemple #2
0
        public override void InitializeDatabase(TimeKeeperContext context)
        {
            try
            {
                // ensure that old database instance can be dropped
                context.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction,
                                                   $"ALTER DATABASE {context.Database.Connection.Database} SET SINGLE_USER WITH ROLLBACK IMMEDIATE");
            }
            catch
            {
                // database does not exists - no problem ;o)
            }
            finally
            {
                base.InitializeDatabase(context);

                using (UnitOfWork unit = new UnitOfWork())
                {
                    addRoles(unit);
                    addTeams(unit);
                    addEmployees(unit);
                    addEngagement(unit);

                    addCustomer(unit);
                    addProjects(unit);

                    addDays(unit);
                    addTasks(unit);
                }
            }
        }
        public override void InitializeDatabase(TimeKeeperContext context)
        {
            try
            {
                context.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction,
                                                   $"ALTER DATABASE {context.Database.Connection.Database} SET SINGLE_USER WITH ROLLBACK IMMEDIATE");
            }
            catch
            {
                //database does not exist, excellent!
            }
            finally
            {
                base.InitializeDatabase(context);

                using (UnitOfWork unit = new UnitOfWork())
                {
                    AddRoles(unit);
                    AddTeams(unit);
                    AddCustomers(unit);
                    AddProjects(unit);
                    AddEmployees(unit);
                    AddDays(unit);
                    AddDetails(unit);
                    AddEngagements(unit);
                }
            }
        }
Exemple #4
0
 private static async Task BuildRelations(Customer entity, TimeKeeperContext context)
 {
     if (entity.Image == null)
     {
         entity.Image = "";
     }
     entity.Status = await context.CustomerStatuses.FindAsync(entity.Status.Id);
 }
Exemple #5
0
        private static async Task BuildRelations(Member entity, TimeKeeperContext context)
        {
            entity.Team = await context.Teams.FindAsync(entity.Team.Id);

            entity.Role = await context.Roles.FindAsync(entity.Role.Id);

            entity.Employee = await context.Employees.FindAsync(entity.Employee.Id);

            entity.Status = await context.MemberStatuses.FindAsync(entity.Status.Id);
        }
Exemple #6
0
        private static async Task BuildRelations(Employee entity, TimeKeeperContext context)
        {
            if (entity.Image == null)
            {
                entity.Image = "";
            }
            entity.EndDate  = new DateTime(1, 1, 1);
            entity.Position = await context.EmployeePositions.FindAsync(entity.Position.Id);

            entity.Status = await context.EmploymentStatuses.FindAsync(entity.Status.Id);
        }
Exemple #7
0
        private static async Task BuildRelations(Project entity, TimeKeeperContext context)
        {
            if (entity.Description == null)
            {
                entity.Description = "";
            }
            entity.Team = await context.Teams.FindAsync(entity.Team.Id);

            entity.Customer = await context.Customers.FindAsync(entity.Customer.Id);

            entity.Status = await context.ProjectStatuses.FindAsync(entity.Status.Id);

            entity.Pricing = await context.PricingStatuses.FindAsync(entity.Pricing.Id);
        }
Exemple #8
0
 public override void InitializeDatabase(TimeKeeperContext context)
 {
     try
     {
         // ensure that old database instance can be dropped
         context.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction,
                                            $"ALTER DATABASE {context.Database.Connection.Database} SET SINGLE_USER WITH ROLLBACK IMMEDIATE");
     }
     catch
     {
         // database does not exists - no problem ;o)
     }
     finally
     {
         base.InitializeDatabase(context);
     }
 }
Exemple #9
0
 public UnitOfWork(TimeKeeperContext context)
 {
     _context = context;
 }
Exemple #10
0
 public TeamsRepository(TimeKeeperContext context) : base(context)
 {
 }
 public MembersRepository(TimeKeeperContext context) : base(context)
 {
 }
Exemple #12
0
        private static async Task BuildRelations(JobDetail entity, TimeKeeperContext context)
        {
            entity.Day = await context.Calendar.FindAsync(entity.Day.Id);

            entity.Project = await context.Projects.FindAsync(entity.Project.Id);
        }
Exemple #13
0
 public Repository(TimeKeeperContext context)
 {
     _context = context;
     _dbSet   = _context.Set <Entity>();
 }
Exemple #14
0
 public CalendarRepository(TimeKeeperContext context) : base(context)
 {
 }
Exemple #15
0
        private static async Task BuildRelations(Day entity, TimeKeeperContext context)
        {
            entity.Employee = await context.Employees.FindAsync(entity.Employee.Id);

            entity.DayType = await context.DayTypes.FindAsync(entity.DayType.Id);
        }
Exemple #16
0
 public RolesRepository(TimeKeeperContext context) : base(context)
 {
 }
 public EmployeesRepository(TimeKeeperContext context) : base(context)
 {
 }
 public AssignmentsRepository(TimeKeeperContext context) : base(context)
 {
 }
 public ProjectsRepository(TimeKeeperContext context) : base(context)
 {
 }
Exemple #20
0
 public CustomersRepository(TimeKeeperContext context) : base(context)
 {
 }