public ItemHoursEntity Create(ItemHoursEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { return provider.Insert<ItemHoursEntity>(entity); } }
public ItemHoursEntity Update(ItemHoursEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { ItemHoursEntity 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<ItemHoursEntity>(entityToUpdate); return entityToUpdate; } }
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; }
private ItemHoursEntry TranslateToItemHoursResponse(ItemHoursEntity entity) { IAuthSession session = this.GetSession(); UserEntity userEntity = SessionUtility.GetSessionUserEntity(session); ItemHoursEntry response = entity.TranslateTo<ItemHoursEntry>(); response.Date = DateTimeUtility.ConvertTimeFromUtc(response.Date, userEntity.TimeZoneId); return response; }
public ItemHoursEntity Delete(ItemHoursEntity entity) { entity.DeletedDate = DateTime.UtcNow; return Update(entity); }
private ItemHoursEntity UpdateProperties(ItemHoursEntity entity, ItemHoursEntity entityToUpdate) { entityToUpdate.HourTypeId = entity.HourTypeId; entityToUpdate.CostCentreId = entity.CostCentreId; entityToUpdate.OrderNumber = entity.OrderNumber; entityToUpdate.RoomNumber = entity.RoomNumber; entityToUpdate.ItemNumber = entity.ItemNumber; entityToUpdate.ParentItemNumber = entity.ParentItemNumber; entityToUpdate.PersonNumber = entity.PersonNumber; entityToUpdate.Hours = entity.Hours; entityToUpdate.Description = entity.Description; entityToUpdate.Date = entity.Date; entityToUpdate.Deleted = entity.Deleted; entityToUpdate.DeletedDate = entity.DeletedDate; return entityToUpdate; }