Beispiel #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);
        }
Beispiel #2
0
        public static House find(int id)
        {
            var   entity = new remax_Entities();
            House h      = entity.Houses.Find(id);

            return(h);
        }
Beispiel #3
0
        public static List <state> get_states()
        {
            var entity = new remax_Entities();
            var query  = (from c in entity.states
                          select c);

            return(query.ToList <state>());
        }
Beispiel #4
0
        public static List <country> get_countries()
        {
            var entity = new remax_Entities();
            var query  = (from c in entity.countries
                          select c);

            return(query.ToList <country>());
        }
Beispiel #5
0
        public static List <House> get_house(string where_key = "1", string where_value = "1")
        {
            var entity = new remax_Entities();

            var query = entity.Database.SqlQuery <House>(string.Format(@"select * from Houses where {0} = '{1}'", where_key, where_value));


            return(query.ToList <House>());
        }
Beispiel #6
0
        public static bool Save_house(House house)
        {
            var entity = new remax_Entities();

            entity.Houses.Add(house);

            entity.SaveChanges();

            return(true);
        }
        public static bool Login(string username, string password)
        {
            var entity = new remax_Entities();

            var result = (from c in entity.Users
                          where c.username == username || c.password == password
                          select c.id).Count();

            if (result == 1)
            {
                return(true);
            }
            return(false);
        }
Beispiel #8
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);
        }
        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);
        }