Пример #1
0
        public async Task <Note> CreateNoteAsync(string title, string name)
        {
            var note = new DAL.Entities.Note(title, name, httpContextAccessor.GetCurrentUserId());

            context.Notes.Add(note);

            await context.SaveChangesAsync();

            return(new Note(note));
        }
Пример #2
0
        public async Task <User> CreateUserAsync(CreateUser createUser)
        {
            if (context.Users.Any(x => x.Username == createUser.Username))
            {
                return(null);
            }

            var passwordHash = passwordHashingService.GetPasswordHash(createUser.Password);

            var user = new DAL.Entities.User(createUser.Username, createUser.FirstName, createUser.LastName, passwordHash);

            context.Users.Add(user);

            await context.SaveChangesAsync();

            return(new User(user));
        }