예제 #1
0
        public User Create(User user, string password)
        {
            // validation
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new AppException("Password is required");
            }

            var userValid = _context.User.FirstOrDefault(u => u.Email == user.Email);

            if (userValid != null)
            {
                throw new AppException("Email \"" + user.Email + "\" is already taken");
            }


            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(password, out passwordHash, out passwordSalt);

            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;

            _context.User.Add(user);
            _context.SaveChanges();

            return(user);
        }
예제 #2
0
 public Language Create(Language language)
 {
     _context.Language.Add(language);
     _context.SaveChanges();
     return(language);
 }
예제 #3
0
 public Work Create(Work work)
 {
     _context.Add(work);
     _context.SaveChanges();
     return(work);
 }
예제 #4
0
 public Education Create(Education education)
 {
     _context.Education.Add(education);
     _context.SaveChanges();
     return(education);
 }
예제 #5
0
 public Portfolio Create(Portfolio portfolio)
 {
     _context.Portfolio.Add(portfolio);
     _context.SaveChanges();
     return(portfolio);
 }
예제 #6
0
 public Skill Create(Skill skill)
 {
     _context.Skill.Add(skill);
     _context.SaveChanges();
     return(skill);
 }