Пример #1
0
        public async Task <Response <string> > RegisterAsync(RegisterModel model)
        {
            var activeUserExists = _context.Users.Any(x => x.Email == model.Email && x.Status != "Deleted");

            if (activeUserExists)
            {
                return(new Response <string>
                {
                    Success = false,
                    Message = "User with such email already exists"
                });
            }

            model.Password = BCrypt.Net.BCrypt.HashPassword(model.Password);

            var newUser = _mapper.Map <User>(model);

            await _context.AddAsync(newUser);

            await _context.SaveChangesAsync();

            string userFullName = $"{newUser.FirstName} {newUser.LastName}";

            return(new Response <string>
            {
                Message = "User was successfully added",
                Data = userFullName
            });
        }
Пример #2
0
        public async Task <AccountEntity> CreateAccountAsync(AccountEntity account)
        {
            await _context.AddAsync(account);

            await _context.SaveChangesAsync();

            return(account);
        }