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)); }
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; }
public FeedRepository(VoteItDBContext context, UserManager <IdentityUser> userManager) { this._context = context; this._userManager = userManager; }
public FeedsController(VoteItDBContext context) { _context = context; }