コード例 #1
0
        public void InsertTestData()
        {
            Helper helper = new Helper();
            User dil = new User();
            dil.UserName = "******";
            dil.Password = helper.EncryptPassword(dil.UserName+"123");
            dil.Role = "Admin";
            String v1 = helper.GenerageVerificationCode(4);
            dil.VerificationCode = v1;

            User laxman = new User();
            laxman.UserName = "******";
            laxman.Password = helper.EncryptPassword(laxman.UserName+"123");
            laxman.Role = "Staff";
            String v2 = helper.GenerageVerificationCode(4);
            laxman.VerificationCode = v2;

            List<User> users = new List<User>();
            users.Add(dil);
            users.Add(laxman);
            using (var db = new GPAEntities())
            {
                db.Users.AddRange(users);
                db.SaveChanges();
            }
        }
コード例 #2
0
        public void RegisterUser(RegisterViewModel model,int userId)
        {
            using (var db = new GPAEntities())
            {
                Registration user = new Registration();
                user.FName = model.RegisterUserViewModel.FName;
                user.LName = model.RegisterUserViewModel.LName;
                user.Email = model.RegisterUserViewModel.Email;
                user.Address = model.RegisterUserViewModel.Address;
                user.City = model.RegisterUserViewModel.City;
                user.Zip = model.RegisterUserViewModel.Zip;
                user.LandNumber = model.RegisterUserViewModel.LandNumber;
                user.MobileNumber = model.RegisterUserViewModel.MobileNumber;
                user.UserID = userId;
                db.Registrations.Add(user);
                db.SaveChanges();

            }
        }