예제 #1
0
        public PropertyViewModel AddProperty(PropertyViewModel newProperty)
        {
            MyHomeDBContext context = new MyHomeDBContext();
            var             prop    = new Property()
            {
                PropertyId       = newProperty.PropertyId,
                GroupLogoUrl     = newProperty.GroupLogoUrl,
                BedsString       = newProperty.BedsString,
                Price            = newProperty.Price,
                SizeStringMeters = newProperty.SizeStringMeters,
                DisplayAddress   = newProperty.DisplayAddress,
                PropertyType     = newProperty.PropertyType,
                BathString       = newProperty.BathString,
                BerRating        = newProperty.BerRating,
                MainPhoto        = newProperty.MainPhoto,
                Photo            = new Photo()
                {
                    DataPhoto = newProperty.Photos
                }
            };

            context.Properties.Add(prop);
            context.SaveChanges();
            return(newProperty);
        }
예제 #2
0
        public Property GetPropertyById(Int32 id)
        {
            MyHomeDBContext context = new MyHomeDBContext();

            var prop = context.Properties.Where(x => x.PropertyId == id).FirstOrDefault();

            return(prop);
        }
예제 #3
0
        public List <Property> GetPropertyList()
        {
            MyHomeDBContext context      = new MyHomeDBContext();
            List <Property> propertyList = new List <Property>();

            propertyList = context.Properties.ToList();
            return(propertyList);
        }
예제 #4
0
        public Boolean DeleteProperty(Int32 id)
        {
            MyHomeDBContext context = new MyHomeDBContext();
            Property        prop    = new Property();

            prop = context.Properties.Where(x => x.PropertyId == id).FirstOrDefault();
            context.Properties.Remove(prop);
            context.SaveChanges();
            return(true);
        }