public int Create(Location locationToCreate) { if (locationToCreate == null) { throw new Exception("The Location sent in for creation is null."); } base.UpdateDateAdded(locationToCreate); base.UpdateIsDeletedToFalse(locationToCreate); db.Locations.Add(locationToCreate); db.SaveChanges(); int idOfLocation = locationToCreate.ID; return idOfLocation; }
public void Delete(Location locationToDelete) { Delete(locationToDelete.ID); }
public int Update(Location updatedLocation) { Location locationToUpdate = db.Locations.SingleOrDefault(i => i.ID == updatedLocation.ID && i.IsDeleted == false); if (locationToUpdate == null) { throw new Exception("No Location exists with the id " + updatedLocation.ID); } locationToUpdate.PrimaryLocation = updatedLocation.PrimaryLocation; locationToUpdate.SecondaryLocation = updatedLocation.SecondaryLocation; base.UpdateDateUpdated(locationToUpdate); db.Locations.AddOrUpdate(l => l.ID, locationToUpdate); db.SaveChanges(); int idOfLocation = locationToUpdate.ID; return idOfLocation; }
public void Destroy(Location locationToDestroy) { Destroy(locationToDestroy.ID); }
private LocationDeleteViewModel ConvertEntityToLocationDeleteViewModel(Location model) { return new LocationDeleteViewModel { ID = model.ID, PrimaryLocation = model.PrimaryLocation, SecondaryLocation = model.SecondaryLocation, }; }
private LocationDisplayViewModel ConvertEntityToLocationDisplayViewModel(Location model) { return new LocationDisplayViewModel { ID = model.ID, PrimaryLocation = model.PrimaryLocation, SecondaryLocation = model.SecondaryLocation, DateAdded = model.DateAdded, DateUpdated = model.DateUpdated }; }