Advertisement
Guest User

seed

a guest
Feb 24th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.34 KB | None | 0 0
  1. public void Seed(Courier.Library.AccountingContext context)
  2. {
  3.  
  4. //var startup = new AccountingLibrary.Models.Startup();
  5. //startup.Seed(context);
  6. var accountTypes = new List<AccountType>
  7. {
  8. new AccountType {Id = 2,Type = "Income",DispayName = "Sales"},
  9. new AccountType {Id = 5,Type = "Expense",DispayName = "Return Sales"},
  10. new AccountType {Id = 11,Type = "Expense",DispayName = "Manufacturing Expense",Real=false},
  11. new AccountType {Id = 21,Type = "Inventory",DispayName = "Opening Stock",Real = false},
  12. new AccountType {Id = 23,Type = "Inventory",DispayName = "Closing Stock",Real = false},
  13. new AccountType {Id = 24,Type = "Expense",DispayName = "Cost of Goods Manufactured",Real = false},
  14. new AccountType {Id = 25,Type = "Expense",DispayName = "Purchase"},
  15. new AccountType {Id = 27,Type = "Income",DispayName = "Return Purchase"},
  16. new AccountType {Id = 35,Type = "Expense",DispayName = "Expenses Operation"},
  17. new AccountType {Id = 41,Type = "Income",DispayName = "Non Operation Income"},
  18. new AccountType {Id = 43,Type = "Expense",DispayName = "Expenses Admin"},
  19. new AccountType {Id = 45,Type = "Expense",DispayName = "Expenses Marketing"},
  20. new AccountType {Id = 47,Type = "Expense",DispayName = "Expenses Financial"},
  21. new AccountType {Id = 51,Type = "Fixed Assets",DispayName = "Fixed Assets"},
  22. new AccountType {Id = 55,Type = "Current Assets",DispayName = "Current Assets"},
  23. new AccountType {Id = 57,Type = "Inventory",DispayName = "Inventories-Raw Material"},
  24. new AccountType {Id = 58,Type = "Inventory",DispayName = "Inventories-Work in Process"},
  25. new AccountType {Id = 59,Type = "Inventory",DispayName = "Inventories-Finished Goods"},
  26. new AccountType {Id = 60,Type = "Persoanl A/c",DispayName = "Personal A/c"},
  27. new AccountType {Id = 72,Type = "Bank",DispayName = "Bank"},
  28. new AccountType {Id = 75,Type = "Cash",DispayName = "Cash"},
  29. new AccountType {Id = 81,Type = "Long Term Liabilities",DispayName = "Long Term Liabilities"},
  30. new AccountType {Id = 83,Type = "Short term Liabilities",DispayName = "Short term Liabilities"},
  31. new AccountType {Id = 85,Type = "Persoanl A/c",DispayName = "Personal A/c",Real = false},
  32. new AccountType {Id = 91,Type = "Equity",DispayName = "Equity"},
  33. new AccountType {Id = 98,Type = "Dividend",DispayName = "Distribution of Income"},
  34. new AccountType {Id = 99,Type = "Acc P&L",DispayName = "Accumulated Profit & Loss"},
  35. };
  36.  
  37. accountTypes.ForEach(a => context.AccountTypes.Add(a));
  38. context.SaveChanges();
  39.  
  40. var roles = new List<Role>() {
  41. new Role{RoleId=Guid.NewGuid(), RoleName="Boss"},
  42. new Role{RoleId=Guid.NewGuid(), RoleName="Admin"},
  43. new Role{RoleId=Guid.NewGuid(), RoleName="CentralEntry"},
  44. new Role{RoleId=Guid.NewGuid(), RoleName="CentralEdit"},
  45. new Role{RoleId=Guid.NewGuid(), RoleName="LocalEntry"},
  46. new Role{RoleId=Guid.NewGuid(), RoleName="LocalEdit"},
  47. new Role{RoleId=Guid.NewGuid(), RoleName="Client"},
  48. new Role{RoleId=Guid.NewGuid(), RoleName="Delivery"},
  49. };
  50.  
  51. roles.ForEach(a => context.Roles.Add(a));
  52. context.SaveChanges();
  53.  
  54. var userRole = roles.Where(r => r.RoleName == "Boss").ToList();
  55. var u = new User()
  56. {
  57. UserId = Guid.NewGuid(),
  58. Username = "BossUser",
  59. Password = Crypto.HashPassword("bosspass"),
  60. Roles = userRole,//(ICollection<Role>)roles.Where(r => r.RoleName == "Boss"),
  61. Privilege = 1,
  62. };
  63. context.Users.Add(u);
  64. context.SaveChanges();
  65.  
  66. var newdate = new DateTime(2015, 1, 1);
  67. var c = new Company()
  68. {
  69. Name = "Meghswar Courier",
  70. SoftStartDate = newdate,
  71. YearStartDate = newdate,
  72. DataClosedUpto = newdate,
  73. LicencedUpto=newdate,
  74. CType = 1,
  75. Id = 1,
  76. };
  77. context.Companies.Add(c);
  78. context.SaveChanges();
  79.  
  80. userRole = roles.Where(r => r.RoleName == "Admin").ToList();
  81. u = new User()
  82. {
  83. UserId = Guid.NewGuid(),
  84. Username = "Admin",
  85. Password = Crypto.HashPassword("1234"),
  86. CompanyId=1,
  87. Roles = userRole,//(ICollection<Role>)roles.Where(r => r.RoleName == "Admin"),
  88. Privilege=2,
  89. };
  90. context.Users.Add(u);
  91. context.SaveChanges();
  92.  
  93. var accounts = new List<Account>()
  94. {
  95. new Account(){AccountName="Accumulated Profit and Loss",AccountTypeId=99},
  96. new Account(){AccountName="Cash",AccountTypeId=75},
  97. new Account(){AccountName="Cash-Junnun",AccountTypeId=75},
  98. new Account(){AccountName="Payment Collectable",AccountTypeId=83},
  99. new Account(){AccountName="Courier Fee",AccountTypeId=2},
  100. };
  101. foreach(var a in accounts)
  102. {
  103. a.CompanyId = 1;
  104. a.Editable = false;
  105. a.CreatorId = u.UserId;
  106. context.Accounts.Add(a);
  107. }
  108.  
  109. context.SaveChanges();
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement