public void Delete(int id) { using (LandPropertiesDBEntities entities = new LandPropertiesDBEntities()) { var mortgage = entities.MORTGAGEs.FirstOrDefault(m => m.ID == id); entities.MORTGAGEs.Remove(mortgage); entities.SaveChanges(); } }
public void Delete(int id) { using (LandPropertiesDBEntities entities = new LandPropertiesDBEntities()) { var ownerToDelete = entities.OWNERs.FirstOrDefault(o => o.ID == id); entities.OWNERs.Remove(ownerToDelete); entities.SaveChanges(); } }
public void Add(LandProperty landProperty) { using (LandPropertiesDBEntities entities = new LandPropertiesDBEntities()) { LAND_PROPERTY dbObjectToAdd = new LAND_PROPERTY(); CopyDataFromBusinessToEFObject(dbObjectToAdd, landProperty); entities.LAND_PROPERTY.Add(dbObjectToAdd); entities.SaveChanges(); } }
public void Edit(LandProperty landProperty) { using (LandPropertiesDBEntities entities = new LandPropertiesDBEntities()) { var dbLandProperty = entities.LAND_PROPERTY.Include("OWNER").Include("MORTGAGEs").FirstOrDefault(lp => lp.ID == landProperty.ID); dbLandProperty.MORTGAGEs.ToList().ForEach(m => entities.MORTGAGEs.Remove(m)); CopyDataFromBusinessToEFObject(dbLandProperty, landProperty); entities.SaveChanges(); } }
public Owner EditOwner(Owner owner) { using (LandPropertiesDBEntities entities = new LandPropertiesDBEntities()) { var dbOwner = entities.OWNERs.FirstOrDefault(o => o.ID == owner.ID); dbOwner.FIRST_NAME = owner.FirstName; dbOwner.LAST_NAME = owner.LastName; dbOwner.ADDRESS = owner.Address; entities.SaveChanges(); return ConvertDbToBusinessEntity(dbOwner); } }
public void Delete(int id) { using (LandPropertiesDBEntities entities = new LandPropertiesDBEntities()) { //Delete mortgages associates to this land property var mortgagesToThisProperty = entities.MORTGAGEs.Where(m => m.LAND_PROPERTY_ID == id).ToList(); mortgagesToThisProperty.ForEach(m => entities.MORTGAGEs.Remove(m)); //Delete the land property var landPropertyToDelete = entities.LAND_PROPERTY.FirstOrDefault(lp => lp.ID == id); entities.LAND_PROPERTY.Remove(landPropertyToDelete); entities.SaveChanges(); } }
public Owner AddOwner(Owner owner) { Owner addedOwner = null; using (LandPropertiesDBEntities entities = new LandPropertiesDBEntities()) { OWNER ownerToAdd = new OWNER { FIRST_NAME = owner.FirstName, LAST_NAME = owner.LastName, ADDRESS = owner.Address }; entities.OWNERs.Add(ownerToAdd); entities.SaveChanges(); addedOwner = ConvertDbToBusinessEntity(ownerToAdd); } return addedOwner; }