예제 #1
0
 public CommentCommandService(
     IRepository<Comment> commentRepository,
     IMathHubDbContext context)
 {
     this.ctx = context.GetDbContext();;
     this.commentRepository = commentRepository;
 }
예제 #2
0
 public BlogCommandService(
     IRepository<Blog> blogRepository,
     IMathHubDbContext context)
 {
     this.ctx = context.GetDbContext();
     this.blogRepository = blogRepository;
 }
예제 #3
0
 public UserQueryService(
     IMathHubDbContext MathHubDbContext,
     IAuthenticationService authenticationService)
 {
     ctx = MathHubDbContext.GetDbContext();
     this._authenticationService = authenticationService;
 }
예제 #4
0
 public DiscussionCommandService(
     IRepository<Discussion> discussionRepository,
     IMathHubDbContext context)
 {
     this.ctx = context.GetDbContext();
     this.discussionRepository = discussionRepository;
 }
예제 #5
0
 public MainPostQueryService(
     IMathHubDbContext mathHubDbContext,
     IPostQueryService postQueryService)
 {
     this.ctx = mathHubDbContext.GetDbContext();
     this._postQueryService = postQueryService;
 }
예제 #6
0
 public ProblemQueryService(
     IMathHubDbContext mathHubDbContext,
     IUserQueryService userQueryService,
     IMainPostQueryService mainPostQueryService)
 {
     ctx = mathHubDbContext.GetDbContext();
     this._userQueryService = userQueryService;
     this._mainPostQueryService = mainPostQueryService;
 }
예제 #7
0
 public TagCommandService(
     IMathHubDbContext ctx,
     IRepository<Tag> tagRepository,
     ILogger logger)
 {
     this.ctx = ctx.GetDbContext();
     this.tagRepository = tagRepository;
     this.logger = logger;
 }
예제 #8
0
 public DiscussionQueryService(
     IRepository<Discussion> discussionRepository,
     IMathHubDbContext context,
     IMainPostQueryService mainPostQuerySerivce)
 {
     this.ctx = context.GetDbContext();
     this._discussionRepository = discussionRepository;
     this._mainPostQuerySerivce = mainPostQuerySerivce;
 }
예제 #9
0
 public FormAuthenticationService(IMathHubDbContext mathHubDbContext)
 {
     // temporary login with Thanh Hai User
     ctx = mathHubDbContext.GetDbContext();
     if (WebSecurity.IsAuthenticated)
     {
         user = ctx.Users.FirstOrDefault(t => t.Username.Equals(WebSecurity.CurrentUserName));
     }
 }
예제 #10
0
파일: Program.cs 프로젝트: hqt/MathHub
 private static void TestReflectionAPI()
 {
     var func = ReflectionUtils.GetExpressionFindId<Problem>(2);
     var func1 = ReflectionUtils.GetExpressionFindId<Post>(2);
     MathHubModelContainer ctx = new MathHubModelContainer();
     Post p = ctx.Posts.Where(func1).FirstOrDefault();
     Problem problem = ctx.Posts.OfType<Problem>().Where(func).FirstOrDefault();
     Console.WriteLine(p.Content);
     Console.WriteLine(problem.Title);
     Console.ReadLine();
 }
예제 #11
0
 public ProblemCommandService(
     IMathHubDbContext MathHubDbContext,
     IRepository<Problem> problemRepository,
     IMainPostCommandService mainPostCommandService,
     ILogger logger
     )
 {
     this.ctx = MathHubDbContext.GetDbContext();
     this.problemRepository = problemRepository;
     this.mainPostCommandService = mainPostCommandService;
     this.logger = logger;
 }
예제 #12
0
        public MathHubDbContext()
        {
            ctx = new MathHubModelContainer();
            // config option for DBContext
            ctx.Configuration.LazyLoadingEnabled = false;
            ctx.Configuration.ProxyCreationEnabled = false;

            // ctx.Configuration.LazyLoadingEnabled = true;
            // ctx.Configuration.ProxyCreationEnabled = true;
            // ctx.Configuration.AutoDetectChangesEnabled = true;

            Console.WriteLine("Create new DBContext");
        }
예제 #13
0
 public UserCommandService(
     IMathHubDbContext context,
     IRepository<User> userRepository,
     IRepository<Profile> profileRepository,
     IRepository<Image> imageRepository,
     IRepository<Activity> activityRepository,
     ILogger logger)
 {
     this.ctx = context.GetDbContext();
     this.userRepository = userRepository;
     this.profileRepository = profileRepository;
     this.imageRepository = imageRepository;
     this.activityRepository = activityRepository;
     this.logger = logger;
 }
예제 #14
0
 public MainPostCommandService(
     IMathHubDbContext MathHubDbContext,
     IRepository<Comment> commentRepository,
     IRepository<Reply> replyRepository,
     IRepository<PostTag> postTagRepository,
     IRepository<FavoritePost> favoritePostRepository,
     IRepository<Share> shareRepository,
     IAuthenticationService authenticationService,
     ILogger logger)
 {
     this.ctx = MathHubDbContext.GetDbContext();
     this.replyRepository = replyRepository;
     this.commentRepository = commentRepository;
     this.postTagRepository = postTagRepository;
     this.authenticationService = authenticationService;
     this.favoritePostRepository = favoritePostRepository;
     this.shareRepository = shareRepository;
     this.logger = logger;
 }
예제 #15
0
 public PermissionCommandService(
     IMathHubDbContext context)
 {
     this.ctx = context.GetDbContext();
 }
예제 #16
0
 public PostQueryService(IMathHubDbContext mathHubDbContext)
 {
     this.ctx = mathHubDbContext.GetDbContext();
 }
예제 #17
0
 public PermissionQueryService(
     IMathHubDbContext context)
 {
     this.ctx = context.GetDbContext();
 }
예제 #18
0
        public virtual ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl)
        {
            string provider = null;
            string providerUserId = null;

            if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId))
            {
                return RedirectToAction("Manage");
            }

            if (ModelState.IsValid)
            {
                // Insert a new user into the database
                using (MathHubModelContainer db = new MathHubModelContainer())
                {
                    User user = db.Users.FirstOrDefault(u => u.Username.ToLower() == model.UserName.ToLower());
                    // Check if user already exists
                    if (user == null)
                    {
                        // Insert name into the profile table
                        db.Users.Add(new User { Username = model.UserName });
                        db.SaveChanges();

                        OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
                        OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false);

                        return RedirectToLocal(returnUrl);
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name.");
                    }
                }
            }

            ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName;
            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }