public CostCentreEntity Create(CostCentreEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { return provider.Insert<CostCentreEntity>(entity); } }
internal static List<ItemHoursEntity> GetItemHoursEntriesForInsert(HourTypeEntity hourType, CostCentreEntity costCentre) { List<ItemHoursEntity> entities = new List<ItemHoursEntity>(); entities.Add(GetItemHoursEntryForInsert(hourType, costCentre)); ItemHoursEntity entity = GetItemHoursEntryForInsert(hourType, costCentre); entity.OrderNumber = 1111; entities.Add(entity); return entities; }
public static CostCentreEntity GetCostCentreForInsert() { CostCentreEntity entity = new CostCentreEntity() { LookupCode = "TCCC", Code = "89", Description = "Test Cost Centre", DeletedDate = DateTime.MinValue }; return entity; }
public CostCentreEntity Update(CostCentreEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { CostCentreEntity entityToUpdate = Read(entity.Id); if (entityToUpdate == null) throw new DataAccessException("Address not found"); // This should not happen seeing that validation should check. entityToUpdate = UpdateProperties(entity, entityToUpdate); provider.Update<CostCentreEntity>(entityToUpdate); return entityToUpdate; } }
public void SetUpRelatedData() { RoomHoursRepository repository = new RoomHoursRepository(ConfigSettings.MySqlDatabaseConnectionName); repository.ClearCollection(); CostCentreRepository costCentreRepository = new CostCentreRepository(ConfigSettings.MySqlDatabaseConnectionName); CostCentreEntity costCentreEntity = HoursData.GetCostCentreForInsert(); costCentreRepository.ClearCollection(); _costCentre = costCentreRepository.Create(costCentreEntity); HourTypeRepository hourTypeRepository = new HourTypeRepository(ConfigSettings.MySqlDatabaseConnectionName); HourTypeEntity hourTypeEntity = HoursData.GetHourTypeForInsert(); hourTypeRepository.ClearCollection(); _hourType = hourTypeRepository.Create(hourTypeEntity); }
public static ItemHoursEntity GetItemHoursEntryForInsert(HourTypeEntity hourType, CostCentreEntity costCentre) { ItemHoursEntity entity = new ItemHoursEntity() { HourTypeId = hourType.Id, CostCentreId = costCentre.Id, OrderNumber = 1234, RoomNumber = 67, ItemNumber = 5678, ParentItemNumber = 8765, PersonNumber = 123456789, Description = "Work on Monday", Date = DateTime.UtcNow, Deleted = true, DeletedDate = DateTime.MinValue }; return entity; }
public CostCentreEntity Delete(CostCentreEntity entity) { entity.DeletedDate = DateTime.UtcNow; return Update(entity); }
private CostCentreEntity UpdateProperties(CostCentreEntity entity, CostCentreEntity entityToUpdate) { entityToUpdate.Code = entity.Code; entityToUpdate.LookupCode = entity.LookupCode; entityToUpdate.Description = entity.Description; entityToUpdate.DeletedDate = entity.DeletedDate; return entityToUpdate; }
private CostCentre TranslateToCostCentreResponse(CostCentreEntity entity) { return entity.TranslateTo<CostCentre>(); }
public static RoomHoursEntity GetRoomHoursEntryForInsert(HourTypeEntity hourType, CostCentreEntity costCentre) { RoomHoursEntity entity = new RoomHoursEntity() { HourTypeId = hourType.Id, CostCentreId = costCentre.Id, ConceptNumber = 9999, OrderNumber = 1234, RoomNumber = 67, PersonNumber = 123456789, Description = "Work on Monday", DeliveryDate = DateTime.UtcNow, Deleted = true, DeletedDate = DateTime.MinValue }; return entity; }