public Customeraccount Create(Customeraccount user, string password)
        {
            // validation
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new AppException("Password is required");
            }

            if (_context.Customeraccount.Any(x => x.EmailId == user.EmailId))
            {
                throw new AppException("Username \"" + user.EmailId + "\" is already taken");
            }

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

            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;
            user.RoleId       = 0;
            //  user.CustId = 0;

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

            return(user);
        }
Пример #2
0
 public Questions AddQuestion(Questions qn, Choicetable op)
 {
     _context.Questions.Add(qn);
     _context.SaveChanges();
     op.QuestionId = qn.QuestionId;
     _context.Choicetable.Add(op);
     _context.SaveChanges();
     return(qn);
 }