/// <summary> /// Gets the data proxy for a given food group identifier. /// </summary> /// <param name="dataProvider">The data provider from which to get the given food group.</param> /// <param name="foodGroupIdentifier">The food group identifier on which to get the data proxy.</param> /// <returns>The data proxy for the given food group identifier.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataProvider"/> is null.</exception> internal static FoodGroupProxy GetFoodGroup(IDataProviderBase <MySqlDataReader, MySqlCommand> dataProvider, Guid foodGroupIdentifier) { ArgumentNullGuard.NotNull(dataProvider, nameof(dataProvider)); using (IFoodWasteDataProvider subDataProvider = (IFoodWasteDataProvider)dataProvider.Clone()) { return(subDataProvider.Get(new FoodGroupProxy { Identifier = foodGroupIdentifier })); } }
/// <summary> /// Gets a given identifiable domain object from the repository. /// </summary> /// <typeparam name="TIdentifiable">Type of the identifiable domain object.</typeparam> /// <typeparam name="TDataProxy">Type of the data proxy for the identifiable domain object.</typeparam> /// <param name="identifier">Identifier for the domain object to get.</param> /// <returns>The identifiable domain object.</returns> protected virtual TIdentifiable Get <TIdentifiable, TDataProxy>(Guid identifier) where TIdentifiable : IIdentifiable where TDataProxy : class, TIdentifiable, IMySqlDataProxy, new() { try { var dataProxy = new TDataProxy { Identifier = identifier }; return(_foodWasteDataProvider.Get(dataProxy)); } catch (IntranetRepositoryException) { throw; } catch (Exception ex) { throw new IntranetRepositoryException(Resource.GetExceptionMessage(ExceptionMessage.RepositoryError, "Get", ex.Message), ex); } }