Ejemplo n.º 1
0
        public int AddUser(UserModel user)
        {
            db.Connection.Open();
            var    users        = db.Users;
            string passkey      = Membership.GeneratePassword(user.Password.Length, 0);
            var    userToInsert = new User {
                Address = user.Address, City = user.City, CPR = user.CPR, Email = user.Email, LastName = user.LastName, FirstName = user.FirstName, GuidLine = user.GuidLine, ZipCode = user.ZipCode, PassKey = passkey
            };

            try
            {
                users.InsertOnSubmit(userToInsert);
                db.SubmitChanges();
            }
            catch (Exception e)
            {
                return(0);
            }
            var password = new Password {
                Password1 = user.Password, UserPassKey = passkey
            };

            try {
                db.Passwords.InsertOnSubmit(password);
                db.SubmitChanges();
            }
            catch (Exception e)
            {
                return(0);
            }
            foreach (var a in user.Allergies)
            {
                UserAllergy allergy = new UserAllergy {
                    AllergyID = a, UserID = users.Single(x => x.CPR == user.CPR).ID
                };
                db.UserAllergies.InsertOnSubmit(allergy);
                db.SubmitChanges();
            }
            db.Connection.Close();
            return(1);
        }
Ejemplo n.º 2
0
 partial void DeleteUserAllergy(UserAllergy instance);
Ejemplo n.º 3
0
 partial void UpdateUserAllergy(UserAllergy instance);
Ejemplo n.º 4
0
 partial void InsertUserAllergy(UserAllergy instance);
Ejemplo n.º 5
0
 private void detach_UserAllergies(UserAllergy entity)
 {
     this.SendPropertyChanging();
     entity.Allergy = null;
 }
Ejemplo n.º 6
0
 private void attach_UserAllergies(UserAllergy entity)
 {
     this.SendPropertyChanging();
     entity.Allergy = this;
 }