Ejemplo n.º 1
0
 public RouteRepository(SafAppDbContext context)
 {
     _context = context;
 }
Ejemplo n.º 2
0
 public UserRepository(SafAppDbContext context)
 {
     _context = context;
 }
Ejemplo n.º 3
0
 public CategoryRepository(SafAppDbContext context)
 {
     _context = context;
 }
Ejemplo n.º 4
0
 public CountryRepository(SafAppDbContext context)
 {
     _context = context;
 }
Ejemplo n.º 5
0
 public ProductRepository(SafAppDbContext context)
 {
     _context = context;
 }
Ejemplo n.º 6
0
 public OutletRepository(SafAppDbContext context)
 {
     _context = context;
 }
Ejemplo n.º 7
0
 public AccountRepository(SafAppDbContext context)
 {
     _context = context;
 }
Ejemplo n.º 8
0
        protected void Seed(SafAppDbContext context)
        {
            Country country = new Country
                                 {
                                     Code = "KE",
                                     CreatedOn = DateTime.Now,
                                     Id = Guid.NewGuid(),
                                     IsActive = true,
                                     UpdatedOn = DateTime.Now,
                                     Name = "Kenya",
                                     ZipCode = "+254"
                                 };

               context.Countries.Add(country);
               Account account = new Account
               {

               CreatedOn = DateTime.Now,
               Id = Guid.NewGuid(),
               IsActive = true,
               UpdatedOn = DateTime.Now,
               Name = "Test Account",

               };

               context.Accounts.Add(account);
               var user1 = new User
                           {
                               CreatedOn = DateTime.Now,
                               Email = "*****@*****.**",
                               Fullname = "Juvenalis Gitau",
                               Id = Guid.NewGuid(),
                               IsActive = true,
                               Password = Md5Hash.GetMd5Hash("1234"),
                               PhoneNumber = "0722557538",
                               UpdatedOn = DateTime.Now,
                               Username = "******",
                               UserType = UserType.Admin,

                               Account = account

                           };
               context.Users.Add(user1);
               var user2 = new User
                           {
                               CreatedOn = DateTime.Now,
                               Email = "*****@*****.**",
                               Fullname = "Patrick Munene",
                               Id = Guid.NewGuid(),
                               IsActive = true,
                               Password = Md5Hash.GetMd5Hash("1234"),
                               PhoneNumber = "0000000000",
                               UpdatedOn = DateTime.Now,
                               Username = "******",
                               UserType = UserType.Admin,
                               Account = account
                           };
               context.Users.Add(user2);

               var category = new Category
               {
               CreatedOn = DateTime.Now,
               Id = Guid.NewGuid(),
               IsActive = true,
               UpdatedOn = DateTime.Now,
               Name = "Sugar",
               Description = "Sugar",
               Account = account
               };

               context.Categories.Add(category);

               var product1 = new Product()
               {
               CreatedOn = DateTime.Now,
               Id = Guid.NewGuid(),
               IsActive = true,
               UpdatedOn = DateTime.Now,
               Name = "Mumias Sugar 1Kg",
               Account = account,
               Category = category,
               BuyingPrice = 20,
               SellingPrice = 30,
               Description = "Sugar"

               };
               context.Products.Add(product1);
               var product2 = new Product()
               {
               CreatedOn = DateTime.Now,
               Id = Guid.NewGuid(),
               IsActive = true,
               UpdatedOn = DateTime.Now,
               Name = "Sony Sugar 1Kg",
               Account = account,
               Category = category,
               BuyingPrice = 20,
               SellingPrice = 30,
               };
               context.Products.Add(product2);
               var route = new Route()
               {
               CreatedOn = DateTime.Now,
               Id = Guid.NewGuid(),
               IsActive = true,
               UpdatedOn = DateTime.Now,
               Name = "Kilimani",
               Account = account,
               AccountId = account.Id,
               Code = "R001"
               };
               context.Routes.Add(route);
               var outlet = new Outlet()
               {
               CreatedOn = DateTime.Now,
               Id = Guid.NewGuid(),
               IsActive = true,
               UpdatedOn = DateTime.Now,
               Name = "Outlet Yaya",
               Account = account,
              AccountId = account.Id,
              Code = "O001",
              Latitude = 31.22,
              Longitude = 1.22,
              Route = route,
              RouteId = route.Id
               };
               context.Outlets.Add(outlet);
               var outlet1 = new Outlet()
               {
               CreatedOn = DateTime.Now,
               Id = Guid.NewGuid(),
               IsActive = true,
               UpdatedOn = DateTime.Now,
               Name = "Outlet Ronga",
               Account = account,
               AccountId = account.Id,
               Code = "O002",
               Latitude = 31.32,
               Longitude = 1.32,
               Route = route,
               RouteId = route.Id
               };
               context.Outlets.Add(outlet1);
               context.SaveChanges();
        }