Esempio n. 1
0
        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;
 }
Esempio n. 3
0
 public UserService(StickyNotesContext dbContext)
 {
     _db = dbContext;
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 public UsersController(StickyNotesContext StickyNotes)
 {
     _StickyNotes = StickyNotes;
 }
Esempio n. 6
0
        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();
        }
Esempio n. 7
0
 public NoteService(StickyNotesContext db)
 {
     _db = db;
 }
Esempio n. 8
0
 public StickyNotesController(StickyNotesContext stickyNotes)
 {
     _stickyNotes = stickyNotes;
 }