예제 #1
0
        public SignUpResponse SignUpUser(SignUpRequest request)
        {
            var errors = new List <string>();

            var user = _context.Set <User>().FirstOrDefault(x => x.Email == request.Email);

            if (user != null)
            {
                errors.Add("The selected email is already in use.");
            }
            else
            {
                user = new User
                {
                    Email    = request.Email,
                    Name     = request.Name,
                    Password = GetHashPassword(request.Password)
                };
            }

            if (errors.Count == 0)
            {
                _context.Add(user);
                _context.SaveChanges();
                return(new SignUpResponse {
                    IsRequestCompleted = true
                });
            }

            return(new SignUpResponse {
                IsRequestCompleted = false, Errors = errors
            });
        }
예제 #2
0
 public Customer Save(Customer customer)
 {
     _context.Set <Customer>().Add(customer);
     _context.SaveChanges();
     return(customer);
 }
예제 #3
0
 public Account Save(Account account)
 {
     _context.Set <Account>().Add(account);
     _context.SaveChanges();
     return(account);
 }