public HttpResponseMessage Insert(MemberProfileAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, string.Join(", ", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage))));
            }
            SuccessResponse response = new SuccessResponse();

            try
            {
                _memberProfileService.Insert(model);
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
예제 #2
0
        public int Insert(MemberProfileAddRequest model)
        {
            try
            {
                int id = 0;
                _baseService.DataProvider.ExecuteNonQuery(_baseService.GetConnection, "dbo.MemberProfile_Insert", inputParamMapper : delegate(SqlParameterCollection paramCollection)
                {
                    paramCollection.AddWithValue("@AspNetUserID", model.AspNetUserID);
                    paramCollection.AddWithValue("@FirstName", model.FirstName);
                    paramCollection.AddWithValue("@MiddleName", model.MiddleName);
                    paramCollection.AddWithValue("@LastName", model.LastName);
                    paramCollection.AddWithValue("@PhoneNumber", model.PhoneNumber);
                    paramCollection.AddWithValue("@Address1", model.Address1);
                    paramCollection.AddWithValue("@Address2", model.Address2);
                    paramCollection.AddWithValue("@City", model.City);
                    paramCollection.AddWithValue("@StateProvinceId", model.StateProvinceId);
                    paramCollection.AddWithValue("@Zip", model.Zip);
                    paramCollection.AddWithValue("@DateOfBirth", model.DateOfBirth);
                    paramCollection.AddWithValue("@Email", model.Email);
                    paramCollection.AddWithValue("@Gender", model.Gender);
                    paramCollection.AddWithValue("@IsActive", model.IsActive);
                    paramCollection.AddWithValue("@IsViewable", model.IsViewable);
                    paramCollection.AddWithValue("@IsGymOwner", model.IsGymOwner);
                    paramCollection.AddWithValue("@CrossfitLevelId", model.CrossFitLevelID);
                    paramCollection.AddWithValue("@IsPublic", model.IsPublic);
                    paramCollection.AddWithValue("@AlertUsingTextMessage", model.AlertUsingTextMessage);
                    paramCollection.AddWithValue("@AlertUsingEmail", model.AlertUsingEmail);

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

                    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, "MemberProfileService");
                throw;
            }
        }