Esempio n. 1
0
 public virtual void Save()
 {
     DbContext.SaveChanges();
 }
Esempio n. 2
0
        public async Task <bool> RegisterUser(string email, string displayName, string password)
        {
            if (displayName == null || displayName.Length > 30)
            {
                // TODO Add proper exception
                throw new InvalidOperationException();
            }

            User user = new User
            {
                UserName    = email,
                Email       = email,
                DisplayName = displayName
            };

            var result = await _userManager.CreateAsync(user, password);

            var registeredUser = await FindUser(email, password);

            var defaultTeam = new Team
            {
                CreatedByUserId = registeredUser.Id,
                Description     = "",
                Default         = true,
                Name            = "My Boards"
            };
            var team = _dbContext.Teams.Add(defaultTeam);

            var userInTeam = new UserInTeam
            {
                Role   = Domain.Enums.UserRoleInTeam.Normal,
                TeamId = team.Id,
                UserId = registeredUser.Id
            };

            _dbContext.UserInTeams.Add(userInTeam);

            var welcomeBoard = new Board
            {
                CreatedByUserId = registeredUser.Id,
                Name            = "Welcome Board"
            };
            var board = _dbContext.Boards.Add(welcomeBoard);

            var boardInTeam = new BoardInTeam
            {
                BoardId = board.Id,
                TeamId  = team.Id
            };

            _dbContext.BoardInTeams.Add(boardInTeam);

            var tag = new Tag
            {
                BoardId         = board.Id,
                Name            = "Getting started",
                CreatedByUserId = registeredUser.Id
            };

            _dbContext.Tags.Add(tag);

            var task1 = new Domain.Models.Task
            {
                CreatedByUserId = registeredUser.Id,
                Title           = "Edit this board with tags that fit you",
                Description     = "Example description... blah blah...",
                TagId           = tag.Id
            };

            _dbContext.Tasks.Add(task1);

            var task2 = new Domain.Models.Task
            {
                CreatedByUserId = registeredUser.Id,
                Title           = "Create to-do tasks of tasks you need to get done",
                Description     = "Example description... blah blah...",
                TagId           = tag.Id
            };

            _dbContext.Tasks.Add(task2);

            _dbContext.SaveChanges();

            return(result.Succeeded);
        }