示例#1
0
        /// <summary>
        /// Adds the meal record.
        /// </summary>
        /// <param name="item">The meal history record.</param>
        /// <returns></returns>
        public async Task <IMealHistoryRecord> AddMealRecord(IMealHistoryRecord item)
        {
            var wrappedRecord = item as MealHistoryRecord;
            var newMealRecord = wrappedRecord != null?wrappedRecord.UnwrapDataObject() : item;

            if (newMealRecord != null)
            {
                using (var dietyContext = DietyDbContext)
                {
                    DietyDbContext.MealHistoryRecords.Add(newMealRecord as MealHistoryRecordDb);
                    await DietyDbContext.SaveChangesAsync();
                }
            }
            return(item);
        }
示例#2
0
        /// <summary>
        /// Adds the meal record.
        /// </summary>
        /// <param name="item">The meal history record.</param>
        /// <returns></returns>
        public async Task <ITraining> AddMealRecord(ITraining item)
        {
            var wrappedRecord = item as Training;
            var newMealRecord = wrappedRecord != null?wrappedRecord.UnwrapDataObject() : item;

            if (newMealRecord != null)
            {
                using (var dietyContext = DietyDbContext)
                {
                    DietyDbContext.Trainings.Add(newMealRecord as TrainingDb);
                    await DietyDbContext.SaveChangesAsync();
                }
            }
            return(item);
        }
示例#3
0
        /// <summary>
        /// Adds the meal record.
        /// </summary>
        /// <param name="item">The ingredient.</param>
        /// <returns></returns>
        public async Task <IIngredient> AddMealRecord(IIngredient item)
        {
            var wrappedRecord = item as Ingredient;
            var newMealRecord = wrappedRecord != null?wrappedRecord.UnwrapDataObject() : item;

            if (newMealRecord != null)
            {
                using (var dietyContext = DietyDbContext)
                {
                    DietyDbContext.Ingredients.Add(newMealRecord as IngredientDb);
                    await DietyDbContext.SaveChangesAsync();
                }
            }
            return(item);
        }