public List<Property> GetAllProperties() { using (var context = new PropertyDb()) { return (from property in context.Property select property).ToList(); } }
public Property GetPropertyByNameAndAddress(string name, string address) { using (var context = new PropertyDb()) { return context.Property.FirstOrDefault(x => x.Name == name && x.Address == address); } }
public void CreateNewProperty(Property property) { using (var context = new PropertyDb()) { context.Property.Add(property); context.SaveChanges(); } }
public void UpdateProperty(int id, Property property) { using (var context = new PropertyDb()) { Property updateProperty = context.Property.SingleOrDefault(p => p.PropertyId == id); if (updateProperty != null) { updateProperty.Address = property.Address; updateProperty.Latitude = property.Latitude; updateProperty.Longitude = property.Longitude; updateProperty.Name = property.Name; context.SaveChanges(); } } }