Exemple #1
0
 public CommentCommandService(
     IRepository<Comment> commentRepository,
     IMathHubDbContext context)
 {
     this.ctx = context.GetDbContext();;
     this.commentRepository = commentRepository;
 }
Exemple #2
0
 public BlogCommandService(
     IRepository<Blog> blogRepository,
     IMathHubDbContext context)
 {
     this.ctx = context.GetDbContext();
     this.blogRepository = blogRepository;
 }
Exemple #3
0
 public UserQueryService(
     IMathHubDbContext MathHubDbContext,
     IAuthenticationService authenticationService)
 {
     ctx = MathHubDbContext.GetDbContext();
     this._authenticationService = authenticationService;
 }
 public DiscussionCommandService(
     IRepository<Discussion> discussionRepository,
     IMathHubDbContext context)
 {
     this.ctx = context.GetDbContext();
     this.discussionRepository = discussionRepository;
 }
Exemple #5
0
 public MainPostQueryService(
     IMathHubDbContext mathHubDbContext,
     IPostQueryService postQueryService)
 {
     this.ctx = mathHubDbContext.GetDbContext();
     this._postQueryService = postQueryService;
 }
Exemple #6
0
 public ProblemQueryService(
     IMathHubDbContext mathHubDbContext,
     IUserQueryService userQueryService,
     IMainPostQueryService mainPostQueryService)
 {
     ctx = mathHubDbContext.GetDbContext();
     this._userQueryService = userQueryService;
     this._mainPostQueryService = mainPostQueryService;
 }
Exemple #7
0
 public TagCommandService(
     IMathHubDbContext ctx,
     IRepository<Tag> tagRepository,
     ILogger logger)
 {
     this.ctx = ctx.GetDbContext();
     this.tagRepository = tagRepository;
     this.logger = logger;
 }
 public DiscussionQueryService(
     IRepository<Discussion> discussionRepository,
     IMathHubDbContext context,
     IMainPostQueryService mainPostQuerySerivce)
 {
     this.ctx = context.GetDbContext();
     this._discussionRepository = discussionRepository;
     this._mainPostQuerySerivce = mainPostQuerySerivce;
 }
 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));
     }
 }
Exemple #10
0
 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();
 }
Exemple #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;
 }
Exemple #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");
        }
Exemple #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;
 }
Exemple #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;
 }
 public PermissionCommandService(
     IMathHubDbContext context)
 {
     this.ctx = context.GetDbContext();
 }
Exemple #16
0
 public PostQueryService(IMathHubDbContext mathHubDbContext)
 {
     this.ctx = mathHubDbContext.GetDbContext();
 }
Exemple #17
0
 public PermissionQueryService(
     IMathHubDbContext context)
 {
     this.ctx = context.GetDbContext();
 }
Exemple #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);
        }