public EmployeeEntity Create(EmployeeEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { return provider.Insert<EmployeeEntity>(entity); } }
public EmployeeEntity Update(EmployeeEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { EmployeeEntity entityToUpdate = Read(entity.Id); if (entityToUpdate == null) throw new DataAccessException("Item not found"); // This should not happen seeing that validation should check. entityToUpdate = UpdateProperties(entity, entityToUpdate); provider.Update<EmployeeEntity>(entityToUpdate); return entityToUpdate; } }
public static EmployeeEntity GetItemForInsert() { EmployeeEntity entity = new EmployeeEntity() { EntityId = ContactDetailsHelpers.CreateEntity().Id, PersonId = ContactDetailsHelpers.CreatePerson().Id, EmploymentStartDate = DateTime.UtcNow, EmploymentEndDate = DateTime.MinValue, DriversLicence = "dddd444444", Passport = "3434455555", HasVehicle = true, StaffAssociation = true, DeletedDate = DateTime.MinValue }; return entity; }
public EmployeeEntity Delete(EmployeeEntity entity) { entity.DeletedDate = DateTime.UtcNow; return Update(entity); }
private EmployeeEntity UpdateProperties(EmployeeEntity entity, EmployeeEntity entityToUpdate) { entityToUpdate.EntityId = entity.EntityId; entityToUpdate.PersonId = entity.PersonId; entityToUpdate.EmploymentStartDate = entity.EmploymentStartDate; entityToUpdate.EmploymentEndDate = entity.EmploymentEndDate; entityToUpdate.DriversLicence = entity.DriversLicence; entityToUpdate.Passport = entity.Passport; entityToUpdate.HasVehicle = entity.HasVehicle; entityToUpdate.StaffAssociation = entity.StaffAssociation; entityToUpdate.DeletedDate = entity.DeletedDate; return entityToUpdate; }