// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% public List <MediaDomain> GetMediaByQRId(int qrId) { List <MediaDomain> mediaList = null; try { // Returns a list of QR-id and media-id pairs. List <QuoteRequestsMediaDomain> mediaItems = GetAllMediaByQuoteRequestId(qrId); // We will be using the media ids to get a list of media domains. if (mediaItems != null) { foreach (QuoteRequestsMediaDomain qrMedia in mediaItems) { MediaService mediaService = new MediaService(); MediaDomain media = mediaService.GetMediaById(qrMedia.MediaId); if (mediaList == null) { mediaList = new List <MediaDomain>(); } mediaList.Add(media); } } } catch (Exception ex) { throw ex; } return(mediaList); }
public RecipeDomain GetRecipeByRecipeId(int RecipeId) { RecipeDomain RecipeDomain = null; MediaDomain MediaDomain = null; IngredientDomain IngredientDomain = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Recipes_GetByRecipeId" , inputParamMapper : delegate(SqlParameterCollection paramcollection) { paramcollection.AddWithValue("@Id", RecipeId); }, map : delegate(IDataReader reader, short set) { if (set == 0) { int startingIndex = 0; RecipeDomain = new RecipeDomain(); RecipeDomain.Id = reader.GetSafeInt32(startingIndex++); RecipeDomain.CreatedDate = reader.GetSafeDateTime(startingIndex++); RecipeDomain.Name = reader.GetSafeString(startingIndex++); RecipeDomain.Description = reader.GetSafeString(startingIndex++); RecipeDomain.Directions = reader.GetSafeString(startingIndex++); RecipeDomain.Preptime = reader.GetSafeInt32(startingIndex++); RecipeDomain.Totaltime = reader.GetSafeInt32(startingIndex++); RecipeDomain.NumberOfServings = reader.GetSafeInt32(startingIndex++); RecipeDomain.UserId = reader.GetSafeString(startingIndex++); MediaDomain = new MediaDomain(); MediaDomain.Id = reader.GetSafeInt32(startingIndex++); MediaDomain.DataType = reader.GetSafeString(startingIndex++); MediaDomain.Url = reader.GetSafeString(startingIndex++); MediaDomain.Created = reader.GetSafeDateTime(startingIndex++); RecipeDomain.Media = MediaDomain; if (RecipeDomain == null) { RecipeDomain = new RecipeDomain(); } } else if (set == 1) { IngredientDomain = new IngredientDomain(); int startingIndex = 0; IngredientDomain.Id = reader.GetSafeInt32(startingIndex++); IngredientDomain.RecipeId = reader.GetSafeInt32(startingIndex++); IngredientDomain.Name = reader.GetSafeString(startingIndex++); IngredientDomain.MeasurementType = reader.GetSafeEnum <IngredientMeasurementType>(startingIndex++); IngredientDomain.Quantity = reader.GetSafeInt32(startingIndex++); RecipeDomain.Ingredients.Add(IngredientDomain); } }); return(RecipeDomain); }
//Get public List <RecipeDomain> GetRecipesByUserId(string UserId) { List <RecipeDomain> ListRecipeDomain = null; MediaDomain MediaDomain = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Recipes_GetAllRecipesByUserId" , inputParamMapper : delegate(SqlParameterCollection paramcollection) { paramcollection.AddWithValue("@userid", UserId); }, map : delegate(IDataReader reader, short set) { RecipeDomain p = new RecipeDomain(); int startingIndex = 0; p.Id = reader.GetSafeInt32(startingIndex++); p.CreatedDate = reader.GetSafeDateTime(startingIndex++); p.Name = reader.GetSafeString(startingIndex++); p.Directions = reader.GetSafeString(startingIndex++); p.Preptime = reader.GetSafeInt32(startingIndex++); p.Totaltime = reader.GetSafeInt32(startingIndex++); p.NumberOfServings = reader.GetSafeInt32(startingIndex++); p.Description = reader.GetSafeString(startingIndex++); MediaDomain = new MediaDomain(); MediaDomain.Id = reader.GetSafeInt32(startingIndex++); MediaDomain.DataType = reader.GetSafeString(startingIndex++); MediaDomain.Url = reader.GetSafeString(startingIndex++); MediaDomain.Created = reader.GetSafeDateTime(startingIndex++); p.Media = MediaDomain; if (ListRecipeDomain == null) { ListRecipeDomain = new List <RecipeDomain>(); } ListRecipeDomain.Add(p); }); return(ListRecipeDomain); }