public int Save(MemberFoodDiaryMealUpdateRequest model)
        {
            try
            {
                int id = 0;
                _baseService.DataProvider.ExecuteNonQuery(_baseService.GetConnection, "dbo.MemberFoodDiaryMeal_Save", inputParamMapper : delegate(SqlParameterCollection paramCollection)
                {
                    paramCollection.AddWithValue("@FoodDiaryMealTypeId", model.FoodDiaryMealTypeId);
                    paramCollection.AddWithValue("@MealDescription", model.MealDescription);
                    paramCollection.AddWithValue("@Calories", model.Calories);
                    paramCollection.AddWithValue("@Carbs", model.Carbs);
                    paramCollection.AddWithValue("@Protein", model.Protein);
                    paramCollection.AddWithValue("@MemberProfileId", model.MemberProfileId);

                    SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int);
                    p.Direction    = System.Data.ParameterDirection.InputOutput;
                    p.Value        = model.Id;

                    paramCollection.Add(p);
                }, returnParameters : delegate(SqlParameterCollection param)
                {
                    int.TryParse(param["@Id"].Value.ToString(), out id);
                });
                return(id);
            }
            catch (Exception ex)
            {
                _baseService.LogError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex, "MemberFoodDiaryMealService");
                throw;
            }
        }
示例#2
0
        public HttpResponseMessage UpdateById(MemberFoodDiaryMealUpdateRequest model)
        {
            SuccessResponse response = new SuccessResponse();

            try
            {
                _memberFoodDiaryMealService.UpdateById(model);
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
示例#3
0
        public HttpResponseMessage Save(MemberFoodDiaryMealUpdateRequest model)
        {
            SuccessResponse response = new SuccessResponse();

            model.MemberProfileId = _memberProfileService.GetCurrentMemberProfile().Id;
            try
            {
                _memberFoodDiaryMealService.Save(model);
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
 public void UpdateById(MemberFoodDiaryMealUpdateRequest model)
 {
     try
     {
         _baseService.DataProvider.ExecuteNonQuery(_baseService.GetConnection, "dbo.MemberFoodDiaryMeal_UpdateById", inputParamMapper : delegate(SqlParameterCollection paramCollection)
         {
             paramCollection.AddWithValue("@Id", model.Id);
             paramCollection.AddWithValue("@FoodDiaryMealTypeId", model.FoodDiaryMealTypeId);
             paramCollection.AddWithValue("@MealDescription", model.MealDescription);
             paramCollection.AddWithValue("@Calories", model.Calories);
             paramCollection.AddWithValue("@Carbs", model.Carbs);
             paramCollection.AddWithValue("@Protein", model.Protein);
             paramCollection.AddWithValue("@MemberProfileId", model.MemberProfileId);
         });
     }
     catch (Exception ex)
     {
         _baseService.LogError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex, "MemberFoodDiaryMealService");
         throw;
     }
 }