Exemplo n.º 1
0
        public static bool update_house(House house)
        {
            var entity = new remax_Entities();

            House h = entity.Houses.Find(house.id);

            if (h != null)
            {
                h.house_number        = house.house_number;
                h.number_of_bathrooms = house.number_of_bathrooms;
                h.number_of_rooms     = house.number_of_rooms;
                h.pool        = house.pool;
                h.fireplace   = house.fireplace;
                h.garage      = house.garage;
                h.city        = house.city;
                h.state       = house.state;
                h.country     = house.country;
                h.price       = house.price;
                h.street_name = house.street_name;
                entity.SaveChanges();
            }
            else
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public static bool Save_house(House house)
        {
            var entity = new remax_Entities();

            entity.Houses.Add(house);

            entity.SaveChanges();

            return(true);
        }
Exemplo n.º 3
0
        public static bool delete(int id)
        {
            var   entity = new remax_Entities();
            House h      = entity.Houses.Find(id);

            if (h != null)
            {
                entity.Houses.Remove(h);
                entity.SaveChanges();

                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        public static bool Register(User user)
        {
            var entity = new remax_Entities();

            var result = (from c in entity.Users
                          where c.username == user.username
                          select c);

            if (result.Count() > 0)
            {
                return(false);
            }

            entity.Users.Add(user);
            //entity.Database.ExecuteSqlCommand(string.Format(@"insert into Users(first_name, last_name, middle_name, username, password, role) values('{0}', '{1}', '{2}', '{3}', '{4}', {5})", user.first_name, user.middle_name, user.last_name, user.username, user.password, user.role));

            entity.SaveChanges();

            return(true);
        }