public ContactTypeEntity Create(ContactTypeEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { return provider.Insert<ContactTypeEntity>(entity); } }
public static ContactTypeEntity GetItemForInsert() { ContactTypeEntity entity = new ContactTypeEntity() { Description = "Type1", DeletedDate = DateTime.MinValue }; return entity; }
public ContactTypeEntity Update(ContactTypeEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { ContactTypeEntity 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<ContactTypeEntity>(entityToUpdate); return entityToUpdate; } }
private static void CreateContactTypes() { ContactTypeRepository repository = new ContactTypeRepository(ConfigSettings.MySqlDatabaseConnectionName); ContactTypeEntity entity = new ContactTypeEntity() { Description = "Email", DeletedDate = DateTime.MinValue }; ContactTypeEntity mEntity = new ContactTypeEntity() { Description = "Mobile", DeletedDate = DateTime.MinValue }; ContactTypeEntity entity3 = new ContactTypeEntity() { Description = "Work Phone", DeletedDate = DateTime.MinValue }; ContactTypeEntity entity4 = new ContactTypeEntity() { Description = "Home Phone", DeletedDate = DateTime.MinValue }; entity = repository.Create(entity); mEntity = repository.Create(mEntity); entity3 = repository.Create(entity3); entity4 = repository.Create(entity4); _contactTypeEntities.Add(entity); _contactTypeEntities.Add(mEntity); _contactTypeEntities.Add(entity3); _contactTypeEntities.Add(entity4); }
public ContactTypeEntity Delete(ContactTypeEntity entity) { entity.DeletedDate = DateTime.UtcNow; return Update(entity); }
private ContactTypeEntity UpdateProperties(ContactTypeEntity entity, ContactTypeEntity entityToUpdate) { entityToUpdate.Description = entity.Description; entityToUpdate.DeletedDate = entity.DeletedDate; return entityToUpdate; }