Ejemplo n.º 1
0
        public async Task DeleteMealDayType(MealDayTypes mealdaytype)
        {
            try
            {
                // Validation
                if (string.IsNullOrWhiteSpace(mealdaytype.Day))
                {
                    throw new Exception("Day is required");
                }
                if (string.IsNullOrWhiteSpace(mealdaytype.Type))
                {
                    throw new Exception("Type is required");
                }

                // Insert/update Food item
                var result = await conn.DeleteAsync(mealdaytype).ConfigureAwait(continueOnCapturedContext: false);

                System.Diagnostics.Debug.WriteLine($"{mealdaytype.Day} - {mealdaytype.Type} has been deleted])");
                StatusMessage = $"{mealdaytype.Day} - {mealdaytype.Type}  has been deleted])";
            }
            catch (Exception ex)
            {
                StatusMessage = $"Unable to delete MealDayType {mealdaytype.Day} - {mealdaytype.Type} . Error: {ex.Message}";
            }
        }
Ejemplo n.º 2
0
        /*
         * MealDayType
         * */

        public async Task CreateMealDayType(MealDayTypes mealdaytype)
        {
            try
            {
                // Validation
                if (string.IsNullOrWhiteSpace(mealdaytype.Day))
                {
                    throw new Exception("Day is required");
                }
                if (string.IsNullOrWhiteSpace(mealdaytype.Type))
                {
                    throw new Exception("Type is required");
                }
                //if (mealdaytype.MealInfoId? == null) throw new Exception("Day is required");

                // Insert/update Food item
                var result = await conn.InsertOrReplaceAsync(mealdaytype).ConfigureAwait(continueOnCapturedContext: false);

                StatusMessage = $"{result} record(s) added [MealDayType: {mealdaytype.Day} - {mealdaytype.Type}])";
            }
            catch (Exception ex)
            {
                StatusMessage = $"Unable to create MealDayType. Error: {ex.Message}";
            }
        }