Example #1
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            //using (MyContext context = new MyContext())
            //{
            //   string name= context.Set<Student>().FirstOrDefault().Name;
            //   name = context.Set<Student>().FirstOrDefault().Courses.FirstOrDefault().Name;
            //}
            //using (MyContext context = new MyContext())
            //{
            //    string name = context.Set<Student>().FirstOrDefault().Name;
            //    name = context.Set<Student>().FirstOrDefault().Courses.FirstOrDefault().Name;
            //}

            using (SCContext a = new SCContext())
            {
                a.Set <Student>().Add(new Student {
                    Name = "1"
                });
                a.SaveChanges();
            }
            //using (UserRoleDbContext2 a = new UserRoleDbContext2())
            //{
            //    a.Set<User>().Add(new User { Name = "1" });
            //    a.SaveChanges();
            //}
            return(Content(""));
        }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var appSettings = services.AddAppSettings(Configuration);

            services.AddHostedService <QueuedHostedBackgroundServicev>();
            services.AddSingleton <IBackgroundTaskQueue, BackgroundTaskQueue>();

            services.AddScoped <SCContextBase, SCContext>((sp) => new SCContext(appSettings));

            services.AddControllersWithViews();

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            // Configure JWT
            var key = Encoding.ASCII.GetBytes(appSettings.Authentication.JwtSecretKey);

            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(x =>
            {
                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = true;
                x.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });


            services.AddSingleton <IChatMessagesQueue, ChatMessagesQueue>();

            services.AddScoped <IUserService, UserService>();

            services.AddHostedService <LogoutExpiredBackgroundService>();

            using (var dbctx = new SCContext(appSettings))
            {
                dbctx.Database.Migrate();
            }

            Action <HttpClient> secServicesConfigClient = client =>
            {
                client.BaseAddress = new Uri(appSettings.StockApiBaseAddress);
                client.DefaultRequestHeaders.Add("Accept", "text/csv; charset=utf-8");
                client.DefaultRequestHeaders.Add("User-Agent", "Mangau Stock Chat");
            };

            services.AddHttpClient <ISockApiClient, StockApiClient>(secServicesConfigClient);
        }
Example #3
0
 public Department GetDepartmentByCode(string code)
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork        uow = new UnitOfWork(context);
         DepartmentBusiness departmentBusiness = new DepartmentBusiness(uow);
         var department = departmentBusiness.GetDepartmentByCode(code);
         return(department);
     }
 }
Example #4
0
 public List <Department> GetAllDepartment()
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork        uow = new UnitOfWork(context);
         DepartmentBusiness departmentBusiness = new DepartmentBusiness(uow);
         var departments = departmentBusiness.GetAllDepartment();
         return(departments.ToList());
     }
 }
Example #5
0
 public List <Student> GetAllStudent()
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork     uow             = new UnitOfWork(context);
         StudentBusiness studentBusiness = new StudentBusiness(uow);
         var             students        = studentBusiness.GetAllStudent();
         return(students.ToList());
     }
 }
 public List <Course> GetAllCourse()
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork    uow            = new UnitOfWork(context);
         CourseBusiness courseBusiness = new CourseBusiness(uow);
         var            courseList     = courseBusiness.GetAllCourse();
         return(courseList.ToList());
     }
 }
 public Course GetCourseByCode(string code)
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork    uow            = new UnitOfWork(context);
         CourseBusiness courseBusiness = new CourseBusiness(uow);
         var            course         = courseBusiness.GetCourseByCode(code);
         return(course);
     }
 }
Example #8
0
 public bool DeleteDepartment(long id)
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork        uow = new UnitOfWork(context);
         DepartmentBusiness departmentBusiness = new DepartmentBusiness(uow);
         bool success = departmentBusiness.DeleteDepartment(id);
         uow.SaveChanges();
         return(success);
     }
 }
 public bool DeleteCourse(long id)
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork    uow            = new UnitOfWork(context);
         CourseBusiness courseBusiness = new CourseBusiness(uow);
         var            course         = courseBusiness.DeleteCourse(id);
         uow.SaveChanges();
         return(true);
     }
 }
Example #10
0
 public bool SaveStudent(Student student)
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork     uow             = new UnitOfWork(context);
         StudentBusiness studentBusiness = new StudentBusiness(uow);
         bool            saved           = studentBusiness.SaveStudent(student);
         uow.SaveChanges();
         return(saved);
     }
 }
Example #11
0
        public Student GetStudentByCode(string code)
        {
            SCContext   context = new SCContext(_contextName);
            IUnitOfWork uow     = new UnitOfWork(context);
            IGenericDataRepository <Student> studentRepo = uow.RepositoryFor <Student>();
            var student = studentRepo.GetSingle(p => p.StudentCode.Equals(code));

            uow.Dispose();
            return(student);
        }
Example #12
0
 public bool SaveDepartment(Department department)
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork        uow = new UnitOfWork(context);
         DepartmentBusiness departmentBusiness = new DepartmentBusiness(uow);
         bool saved = departmentBusiness.SaveDepartment(department);
         uow.SaveChanges();
         return(saved);
     }
 }
 public bool SaveCourse(Course course)
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork    uow            = new UnitOfWork(context);
         CourseBusiness courseBusiness = new CourseBusiness(uow);
         bool           saved          = courseBusiness.SaveCourse(course);
         uow.SaveChanges();
         return(saved);
     }
 }
Example #14
0
 public bool DeleteStudent(long id)
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork     uow             = new UnitOfWork(context);
         StudentBusiness studentBusiness = new StudentBusiness(uow);
         bool            saved           = studentBusiness.SaveStudent(new Student {
             StudentID = id, EntityState = EntityState.Deleted
         });
         uow.SaveChanges();
         return(saved);
     }
 }
Example #15
0
        private static void Main(string[] args)
        {
            using (var db = new SCContext())
            {
                Console.WriteLine("Preparing database...");

                db.Database.EnsureDeleted();
                db.Database.EnsureCreated();

                Console.WriteLine("Done");
            }
        }
Example #16
0
 public MaterialsService(SCContext _context)
 {
     db = _context;
 }
Example #17
0
 public UserRepository(SCContext context) : base(context)
 {
     this.context = context;
 }
 public EXArticleRankList(SCContext context, IMemoryCache memoryCache)
 {
     db           = context;
     _memoryCache = memoryCache;
 }
Example #19
0
 public AskService(SCContext _context)
 {
     db = _context;
 }
Example #20
0
 public TopicStatistics(SCContext context, IMemoryCache memoryCache)
 {
     db           = context;
     _memoryCache = memoryCache;
 }
Example #21
0
 public TournamentRepository(SCContext context) : base(context)
 {
     this.context = context;
 }
Example #22
0
 public GroupRepository(SCContext context) : base(context)
 {
     this.context = context;
 }
Example #23
0
 public BreakRepository(SCContext context) : base(context)
 {
     this.context = context;
 }
Example #24
0
 public LeagueRepository(SCContext context) : base(context)
 {
     this.context = context;
 }
Example #25
0
 public EXArticleTempService(SCContext _context)
 {
     db = _context;
 }
 public FrameRepository(SCContext context) : base(context)
 {
     this.context = context;
 }
Example #27
0
 public PlayerPositionTournamentRepository(SCContext context) : base(context)
 {
     this.context = context;
 }
Example #28
0
 public TopicRankList(SCContext context, IMemoryCache memoryCache)
 {
     db           = context;
     _memoryCache = memoryCache;
 }
 public StartupServiceImpl(SCContext sCContext)
 {
     _dbcontext = sCContext;
 }
 public MaterialsRankList(SCContext context, IMemoryCache memoryCache)
 {
     db           = context;
     _memoryCache = memoryCache;
 }