public Form1() { var db = new StickyNotesContext(); _userService = new UserService(db); _noteService = new NoteService(db); InitializeComponent(); var users = _userService.GetUsersByTeamId(1); foreach (var user in users) { NameBox.Items.Add(user.EmailAddress); } }
public NoteRepository(StickyNotesContext context) { _context = context; }
public UserService(StickyNotesContext dbContext) { _db = dbContext; }
public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); var db = new StickyNotesContext(); var newTeam = new Team { Name = model.TeamName, AdminId = user.Id }; var newUser = new User { EmailAddress = model.Email, UserName = model.UserName, Team = newTeam, TeamId = newTeam.Id }; db.User.Add(newUser); db.Team.Add(newTeam); db.SaveChanges(); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return RedirectToAction("Index", "Home"); } AddErrors(result); } // If we got this far, something failed, redisplay form return View(model); }
public UsersController(StickyNotesContext StickyNotes) { _StickyNotes = StickyNotes; }
public async Task<IHttpActionResult> Register(RegisterBindingModel model) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var user = new ApplicationUser() { UserName = model.Email, Email = model.Email }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); // this needs to change var db = new StickyNotesContext(); var userTeam = new User { EmailAddress = model.Email, TeamId = model.TeamId }; db.User.Add(userTeam); db.SaveChanges(); if (!result.Succeeded) { return GetErrorResult(result); } return Ok(); }
public NoteService(StickyNotesContext db) { _db = db; }
public StickyNotesController(StickyNotesContext stickyNotes) { _stickyNotes = stickyNotes; }