Пример #1
0
        public void Register(UserModel user)
        {
            using (var db = new shamethethronesContext())
            {
                User newUser = new User();

                newUser.username = user.UserName;
                newUser.email = user.Email;
                newUser.pasword = CalculateMD5Hash(user.Password);
                
                db.Users.Add(newUser);
                db.SaveChanges();
            }
        }
Пример #2
0
        public int UserId; // later on will be required

        public void add()
        {
            using (var db = new shamethethronesContext())
            {
                var rating = new Rating();
                rating.userId = this.UserId;
                rating.comment = this.Comment;
                rating.restroomId = this.RestroomId;
                rating.title = this.Title;
                rating.ratingValue = (byte) this.Rating;
                db.Ratings.Add(rating);
                db.SaveChanges();
            }
        }
Пример #3
0
 public void AddRestroom(RestroomModel bathroom)
 {
     using (var db = new shamethethronesContext())
     {
         Restroom newBathroom = new Restroom();
         newBathroom.userId = bathroom.userId;
         newBathroom.address = bathroom.Address;
         newBathroom.city = bathroom.City; // commented out until db is changed 
         newBathroom.state = bathroom.State; 
         newBathroom.zipCode = Int32.Parse(bathroom.ZipCode); 
         newBathroom.gender = bathroom.Gender;
         newBathroom.description = bathroom.Description;
         newBathroom.coordX = bathroom.coordX;
         newBathroom.coordY = bathroom.coordY;
         db.Restrooms.Add(newBathroom);
         db.SaveChanges(); //until testing is done
         bathroom.id = newBathroom.id; // sets the id so we can get it later
     }
 }