public List <Staff> ListStaff() { using (var context = new PracticeContext()) { return(context.Staffs.ToList()); } }
public static void OrderItemMock(PracticeContext context) { if (context.OrderItems.Any()) { return; } context.OrderItems.AddRange(context.Order.ToArray().Select(c => CreateOrderItem(c.Id, context))); }
public static void OrderMock(PracticeContext context) { if (context.Order.Any()) { return; } context.Order.AddRange(Enumerable.Range(1, 5).Select(c => CreateOrder(c, context))); context.SaveChanges(); }
public static OrderItem CreateOrderItem(int orderId, PracticeContext practiceContext) { Random random = new Random(); var cost = random.Next(50, 200); return(new OrderItem() { OrderId = orderId, CreateDate = DateTime.Now, UpdateDate = DateTime.Now }); }
public static void CreateUser(PracticeContext context) { var user = new User() { Username = "******", Password = "", SecurityToken = "", Name = "Ball", CreateDate = DateTime.Now, UpdateDate = DateTime.Now }; context.Add(user); context.SaveChanges(); }
public static Order CreateOrder(int Id, PracticeContext context) { var suppliers = context.Suppliers.ToArray(); return(new Order() { Name = "Receipt_" + Id, SupplierId = suppliers.FirstOrDefault().Id, OrderItems = context.Items.Take(3).Select(c => new OrderItem { Item = c }).ToList(), CreateDate = DateTime.Now, UpdateDate = DateTime.Now }); }
public static void SupplierMock(PracticeContext context) { if (context.Suppliers.Any()) { return; } context.Suppliers.AddRange(Enumerable.Range(1, 5).Select(c => new Supplier { Name = "Supplier_" + c, Address = "Thailand", PhoneNo = "084-874" + c, CreateDate = DateTime.Now, UpdateDate = DateTime.Now })); context.SaveChanges(); }
public static void ActionStateMock(PracticeContext context) { if (context.ActionStates.Any()) { return; } var user = context.Users.FirstOrDefault(); var action = new ActionState() { By = user.Id, On = DateTime.Now.Ticks }; context.ActionStates.Add(action); context.SaveChanges(); }
public static void OrdersStateMock(PracticeContext context) { if (context.OrderStates.Any()) { return; } var order = context.Order.ToArray().Select(c => new OrderState { OrderId = c.Id, Type = StateType.Get, ActionStateId = context.ActionStates.Select(x => x.Id).FirstOrDefault(), CreateDate = DateTime.Now, UpdateDate = DateTime.Now }); context.OrderStates.AddRange(order); context.SaveChanges(); }
public static void ItemsStateMock(PracticeContext context) { if (context.ItemStates.Any()) { return; } var item = context.Items.ToArray().Select(c => new ItemState { ItemId = c.Id, Type = StateType.Get, ActionStateId = context.ActionStates.Select(x => x.Id).FirstOrDefault(), CreateDate = DateTime.Now, UpdateDate = DateTime.Now }); context.ItemStates.AddRange(item); context.SaveChanges(); }
public static Item CreateItems(int i, PracticeContext practiceContext) { Random random = new Random(); var cost = random.Next(50, 200); return(new Item() { Name = "Item_" + i, Cost = cost, Unit = 10, SKU = SKU.Beverage, Barcode = i + "Items" + i, ItemSupplier = practiceContext.Suppliers.Take(2).Select(c => new ItemSupplier { Supplier = c }).ToList(), CreateDate = DateTime.Now, UpdateDate = DateTime.Now }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); try { var practiceContext = new PracticeContext(GetOptions(Configuration.GetConnectionString("DefaultConnection"))); if (!practiceContext.Database.CanConnect()) { practiceContext.Database.Migrate(); practiceContext.EnsureSeeded(); } } catch (SqlException) { } } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1"); }); }
private static void AddTopics(PracticeContext context) { var topicList = new List <Topic> { new Topic { TopicId = "TAdd", TopicDesc = "Addition" }, new Topic { TopicId = "TSub", TopicDesc = "Subtraction" }, new Topic { TopicId = "TMul", TopicDesc = "Multiplication" }, new Topic { TopicId = "TDiv", TopicDesc = "Division" }, new Topic { TopicId = "TAlg", TopicDesc = "Algebra" }, new Topic { TopicId = "TDec", TopicDesc = "Decimal" }, new Topic { TopicId = "TFra", TopicDesc = "Fraction" }, new Topic { TopicId = "TNum", TopicDesc = "Number Sense" }, new Topic { TopicId = "TInt", TopicDesc = "Integers" }, }; topicList.ForEach(s => context.Topics.Add(s)); context.SaveChanges(); Console.WriteLine("updated topics"); }
private static PracticeContext GetDbContext() { PracticeContext context = null; try { //Database.SetInitializer<PracticeContext>(new CreateDatabaseIfNotExists<PracticeContext>()); context = new PracticeContext(connectionString); //AddTopics(context); //AddSubTopics(); //AddCompleteQuestions(); int i = context.Topics.Count(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(context); }
public loginuserController(PracticeContext practiceContext) { _privatecontext = practiceContext; }
public CategoriesController(PracticeContext context) { _context = context; }
public DepartmentController(PracticeContext practiceContext) { _practiceContext = practiceContext; }
// here we can "inject" our context service into the constructor public HomeController(PracticeContext context) { dbContext = context; }
public ProductsController(PracticeContext context) { _context = context; }
public SupplierRepository(PracticeContext practiceContext) { this.practiceContext = practiceContext; }
public OrderItemRepository(PracticeContext practiceContext) { this.practiceContext = practiceContext; }
public AddressesController(PracticeContext context) { _context = context; }
public GenericRepository(PracticeContext dbContext) { _dbContext = dbContext; _entities = _dbContext.Set <T>(); }
public PostController(ILogger <PostController> logger, PracticeContext practiceContext) { _logger = logger; this._practiceContext = practiceContext; }
public MemberController(PracticeContext context) { _context = context; }
public PracticeRepository() { _context = new PracticeContext(); }
public GamesController(PracticeContext context) { _context = context; }
public PracticeController(PracticeContext context) => _context = context;
public void UpdateContext(PracticeContext context) { //Membership.CreateUser(“testuser”, “test123″); //Roles.CreateRole(“Administrator”); //Roles.AddUsersToRole(new[] {“testuser”}, “Administrator”); var topicList = new List <Topic> { new Topic { TopicId = "TAdd", TopicDesc = "Adddition" }, new Topic { TopicId = "TSub", TopicDesc = "Subtraction" }, new Topic { TopicId = "TMul", TopicDesc = "Multipication" }, new Topic { TopicId = "TDiv", TopicDesc = "Division" }, new Topic { TopicId = "TAlg", TopicDesc = "Algebra" }, new Topic { TopicId = "TCom", TopicDesc = "Compare" }, new Topic { TopicId = "TFra", TopicDesc = "Fraction" }, new Topic { TopicId = "TDec", TopicDesc = "Decimal" }, new Topic { TopicId = "TPAl", TopicDesc = "Pre-Algebra" }, new Topic { TopicId = "TWor", TopicDesc = "WordProblem" }, }; topicList.ForEach(s => context.Topics.Add(s)); context.SaveChanges(); var subTopicList = new List <SubTopic> { //Add new SubTopic { SubTopicId = "1001", SubTopicDesc = "Additions 1 to 9", TopicId = "TAdd" }, new SubTopic { SubTopicId = "1002", SubTopicDesc = "Additions 1 to 100", TopicId = "TAdd" }, new SubTopic { SubTopicId = "1003", SubTopicDesc = "Two Digit Additions 11-20 with 11-20", TopicId = "TAdd" }, new SubTopic { SubTopicId = "1004", SubTopicDesc = "Two Digit Additions with Regrouping", TopicId = "TAdd" }, //Sub new SubTopic { SubTopicId = "1101", SubTopicDesc = "Subtraction 1 to 9", TopicId = "TSub" }, new SubTopic { SubTopicId = "1102", SubTopicDesc = "Subtraction 1 to 100", TopicId = "TSub" }, new SubTopic { SubTopicId = "1103", SubTopicDesc = "Two Digit Subtraction 11-20 with 11-20", TopicId = "TSub" }, new SubTopic { SubTopicId = "1104", SubTopicDesc = "Two Digit Subtraction with Regrouping", TopicId = "TSub" }, //Mul new SubTopic { SubTopicId = "1201", SubTopicDesc = "Multiplication by 1", TopicId = "TMul" }, new SubTopic { SubTopicId = "1202", SubTopicDesc = "Multiplication by 2", TopicId = "TMul" }, new SubTopic { SubTopicId = "1203", SubTopicDesc = "Multiplication by 3", TopicId = "TMul" }, new SubTopic { SubTopicId = "1204", SubTopicDesc = "Multiplication by 4", TopicId = "TMul" }, new SubTopic { SubTopicId = "1205", SubTopicDesc = "Multiplication by 5", TopicId = "TMul" }, new SubTopic { SubTopicId = "1206", SubTopicDesc = "Multiplication by 6", TopicId = "TMul" }, new SubTopic { SubTopicId = "1207", SubTopicDesc = "Multiplication by 7", TopicId = "TMul" }, new SubTopic { SubTopicId = "1208", SubTopicDesc = "Multiplication by 8", TopicId = "TMul" }, new SubTopic { SubTopicId = "1209", SubTopicDesc = "Multiplication by 9", TopicId = "TMul" }, new SubTopic { SubTopicId = "1210", SubTopicDesc = "Multiplication by 10", TopicId = "TMul" }, new SubTopic { SubTopicId = "1211", SubTopicDesc = "Multiplication by 11", TopicId = "TMul" }, new SubTopic { SubTopicId = "1212", SubTopicDesc = "Multiplication by 12", TopicId = "TMul" }, //new SubTopic { SubTopicId="1213", SubTopicDesc ="Multiplication by 8", TopicId="TMul" }, //Division new SubTopic { SubTopicId = "1301", SubTopicDesc = "Division 1 to 9", TopicId = "TDiv" }, new SubTopic { SubTopicId = "1302", SubTopicDesc = "Division 1 to 100", TopicId = "TDiv" }, new SubTopic { SubTopicId = "1303", SubTopicDesc = "Two Digit Division 11-20 with 11-20", TopicId = "TDiv" }, new SubTopic { SubTopicId = "1304", SubTopicDesc = "Two Digit Division with Regrouping", TopicId = "TDiv" }, //Algebra new SubTopic { SubTopicId = "2001", SubTopicDesc = "Algebra for Addition", TopicId = "TAlg" }, new SubTopic { SubTopicId = "2101", SubTopicDesc = "Algebra for Subraction", TopicId = "TAlg" }, new SubTopic { SubTopicId = "2201", SubTopicDesc = "Algebra involving Mulitplication", TopicId = "TAlg" }, new SubTopic { SubTopicId = "2301", SubTopicDesc = "Algebra involving Division", TopicId = "TAlg" }, }; subTopicList.ForEach(s => context.SubTopics.Add(s)); context.SaveChanges(); //add the Grades Table // var gradeList = GradeList ?? SimpleInit.GetHardCodedGrades(); var gradeList = new List <Grade> { //Add new Grade { GradeId = "-1", GradeDesc = "Pre-K", GradeDesc2 = "PreSchool" }, new Grade { GradeId = "0", GradeDesc = "KinderGarten", GradeDesc2 = "KinderGarten" }, new Grade { GradeId = "1", GradeDesc = "Grade1", GradeDesc2 = "Grade1" }, new Grade { GradeId = "2", GradeDesc = "Grade2", GradeDesc2 = "Grade2" }, new Grade { GradeId = "3", GradeDesc = "Grade3", GradeDesc2 = "Grade3" }, new Grade { GradeId = "4", GradeDesc = "Grade4", GradeDesc2 = "Grade4" }, new Grade { GradeId = "5", GradeDesc = "Grade5", GradeDesc2 = "Grade5" }, new Grade { GradeId = "6", GradeDesc = "Grade6", GradeDesc2 = "Grade6" }, new Grade { GradeId = "7", GradeDesc = "Grade7", GradeDesc2 = "Grade7" }, new Grade { GradeId = "8", GradeDesc = "Grade8", GradeDesc2 = "Grade8" }, }; gradeList.ForEach(s => context.Grades.Add(s)); context.SaveChanges(); //var gradeSubTopicList = GradeSubTopicList ?? SimpleInit.GetHardCodedGrade_Subtopic(); var gradeSubTopicList = new List <GradeSubTopic> { new GradeSubTopic { GradeId = "-1", SubTopicId = "1001" }, new GradeSubTopic { GradeId = "-1", SubTopicId = "1002" }, new GradeSubTopic { GradeId = "0", SubTopicId = "1001" }, new GradeSubTopic { GradeId = "0", SubTopicId = "1002" }, new GradeSubTopic { GradeId = "0", SubTopicId = "1101" }, new GradeSubTopic { GradeId = "0", SubTopicId = "1102" }, new GradeSubTopic { GradeId = "1", SubTopicId = "1001" }, new GradeSubTopic { GradeId = "1", SubTopicId = "1002" }, new GradeSubTopic { GradeId = "1", SubTopicId = "1101" }, new GradeSubTopic { GradeId = "1", SubTopicId = "1102" }, new GradeSubTopic { GradeId = "1", SubTopicId = "1003" }, new GradeSubTopic { GradeId = "1", SubTopicId = "1004" }, new GradeSubTopic { GradeId = "1", SubTopicId = "1103" }, new GradeSubTopic { GradeId = "1", SubTopicId = "1104" }, new GradeSubTopic { GradeId = "2", SubTopicId = "1001" }, new GradeSubTopic { GradeId = "2", SubTopicId = "1002" }, new GradeSubTopic { GradeId = "2", SubTopicId = "1101" }, new GradeSubTopic { GradeId = "2", SubTopicId = "1102" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1201" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1202" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1203" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1204" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1205" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1206" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1207" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1208" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1209" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1210" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1211" }, new GradeSubTopic { GradeId = "3", SubTopicId = "1212" }, new GradeSubTopic { GradeId = "4", SubTopicId = "1201" }, new GradeSubTopic { GradeId = "4", SubTopicId = "1202" }, new GradeSubTopic { GradeId = "4", SubTopicId = "1203" }, new GradeSubTopic { GradeId = "4", SubTopicId = "1204" }, new GradeSubTopic { GradeId = "4", SubTopicId = "1205" }, new GradeSubTopic { GradeId = "5", SubTopicId = "1201" }, new GradeSubTopic { GradeId = "5", SubTopicId = "1202" }, new GradeSubTopic { GradeId = "5", SubTopicId = "1203" }, new GradeSubTopic { GradeId = "5", SubTopicId = "1204" }, new GradeSubTopic { GradeId = "5", SubTopicId = "1205" }, new GradeSubTopic { GradeId = "6", SubTopicId = "1201" }, new GradeSubTopic { GradeId = "6", SubTopicId = "1202" }, new GradeSubTopic { GradeId = "6", SubTopicId = "1203" }, new GradeSubTopic { GradeId = "6", SubTopicId = "1204" }, new GradeSubTopic { GradeId = "6", SubTopicId = "1205" }, new GradeSubTopic { GradeId = "7", SubTopicId = "1201" }, new GradeSubTopic { GradeId = "7", SubTopicId = "1202" }, new GradeSubTopic { GradeId = "7", SubTopicId = "1203" }, new GradeSubTopic { GradeId = "7", SubTopicId = "1204" }, new GradeSubTopic { GradeId = "7", SubTopicId = "1205" }, new GradeSubTopic { GradeId = "8", SubTopicId = "1201" }, new GradeSubTopic { GradeId = "8", SubTopicId = "1202" }, new GradeSubTopic { GradeId = "8", SubTopicId = "1203" }, new GradeSubTopic { GradeId = "8", SubTopicId = "1204" }, new GradeSubTopic { GradeId = "8", SubTopicId = "1205" }, }; gradeSubTopicList.ForEach(s => context.GradeSubTopics.Add(s)); context.SaveChanges(); var questionList = QuestionList ?? SimpleInit.GetHardCodedQuestions(); questionList.ForEach(s => context.Questions.Add(s)); context.SaveChanges(); var answerOptionsList = AnswerOptionList ?? SimpleInit.GetHardCodedAnsweOptions(); answerOptionsList.ForEach(s => context.AnswerOptions.Add(s)); context.SaveChanges(); var questionDetailList = QuestionDetailList ?? SimpleInit.GetHardCodedQuestionDetails(); questionDetailList.ForEach(s => context.QuestionDetails.Add(s)); context.SaveChanges(); //add the Sheet Tables var sheetList = SheetList ?? SimpleInit.GenerateSheetList(); sheetList.ForEach(s => context.Sheet.Add(s)); context.SaveChanges(); //add the Question Sheet details var questionSheetList = QuestionSheetList ?? SimpleInit.GenerateQuestionSheetList(); questionSheetList.ForEach(s => context.QuestionSheet.Add(s)); context.SaveChanges(); }
public DentistController(PracticeContext context) { _context = context; }