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); }
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); }