コード例 #1
0
		public CostCentreEntity Create(CostCentreEntity entity)
		{
			using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName))
			{
				return provider.Insert<CostCentreEntity>(entity);
			}
		}
コード例 #2
0
		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;
		}
コード例 #3
0
		public static CostCentreEntity GetCostCentreForInsert()
		{
			CostCentreEntity entity = new CostCentreEntity()
			{
				LookupCode = "TCCC",
				Code = "89",
				Description = "Test Cost Centre",
				DeletedDate = DateTime.MinValue
			};

			return entity;
		}
コード例 #4
0
		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;
			}
		}
コード例 #5
0
		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);
		}
コード例 #6
0
		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;
		}
コード例 #7
0
		public CostCentreEntity Delete(CostCentreEntity entity)
		{
			entity.DeletedDate = DateTime.UtcNow;

			return Update(entity);
		}
コード例 #8
0
		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;
		}
コード例 #9
0
		private CostCentre TranslateToCostCentreResponse(CostCentreEntity entity)
		{
			return entity.TranslateTo<CostCentre>();
		}
コード例 #10
0
		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;
		}