예제 #1
0
        public async Task <ActionResult> Create([Bind("FeedTitle")] Feed feed)
        {
            var user = await this._userManager.GetUserAsync(User);

            if (user == null)
            {
                //throw new Exception("尚未認證");
            }

            feed.FeedCreatedDateTime = DateTime.Now;
            feed.FeedCreatedUser     = user.Email;
            feed.FeedLike            = 0;
            feed.FeedValidFlag       = true;

            // TODO: Add insert logic here
            if (ModelState.IsValid)
            {
                using (var context = new VoteItDBContext())
                {
                    context.Add(feed);
                    await context.SaveChangesAsync();
                }

                return(RedirectToAction(nameof(Index)));
            }
            return(View(feed));
        }
예제 #2
0
 public FeedsController(VoteItDBContext context,
                        FeedRepository feedRepository,
                        UserManager <IdentityUser> userManager,
                        UserRepository userRepository,
                        NotifyService notifyService,
                        FeedService feedService)
 {
     this._context        = context;
     this._feedRepositry  = feedRepository;
     this._userManager    = userManager;
     this._userRepository = userRepository;
     this._notifyService  = notifyService;
     this._feedService    = feedService;
 }
예제 #3
0
 public FeedRepository(VoteItDBContext context,
                       UserManager <IdentityUser> userManager)
 {
     this._context     = context;
     this._userManager = userManager;
 }
예제 #4
0
 public FeedsController(VoteItDBContext context)
 {
     _context = context;
 }