Пример #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dbContext">A reference to the database context</param>
 public UserRepository(PocDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Пример #2
0
        /// <summary>
        /// Seeds the database with mock data
        /// </summary>
        /// <param name="context"></param>
        public static void Initialize(PocDbContext context)
        {
            context.Database.EnsureCreated();

            if (context.Users.Any())
            {
                return;
            }

            var users = new User[]
            {
                new User {
                    Id       = 1,
                    Username = "******",
                    Password = "******",
                    RoleId   = Role.USER.Id
                },
                new User {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    RoleId   = Role.ADMIN.Id
                }
            };

            context.AddRange(users);
            context.SaveChanges();

            var demands = new ServiceDemand[]
            {
                new ServiceDemand
                {
                    CreatedAt   = DateTime.Now,
                    Description = "Service 1",
                    LastEdit    = DateTime.Now,
                    StatusId    = Status.CREATED.Id,
                    OwnerId     = users[0].Id
                },
                new ServiceDemand
                {
                    CreatedAt   = DateTime.Now,
                    Description = "Service 2",
                    LastEdit    = DateTime.Now,
                    StatusId    = Status.CREATED.Id,
                    OwnerId     = users[0].Id
                },
                new ServiceDemand
                {
                    CreatedAt   = DateTime.Now,
                    Description = "Service 3",
                    LastEdit    = DateTime.Now,
                    StatusId    = Status.IN_ANALISYS.Id,
                    OwnerId     = users[1].Id
                },
                new ServiceDemand
                {
                    CreatedAt   = DateTime.Now,
                    Description = "Service 4",
                    LastEdit    = DateTime.Now,
                    StatusId    = Status.IN_PROGRESS.Id,
                    OwnerId     = users[1].Id
                }
            };

            context.AddRange(demands);
            context.SaveChanges();
        }
Пример #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="context">DbContext instance</param>
 public DemandsRepository(PocDbContext context)
 {
     _dbContext = context;
 }