示例#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);
 }