コード例 #1
0
        public int Add(TherapistAddRequest model, int userId)
        {
            int id = 0;

            string procName = "[dbo].[Therapists_Insert]";

            _data.ExecuteNonQuery(procName,
                                  inputParamMapper : delegate(SqlParameterCollection col)
            {
                AddCommonParams(model, col, userId);



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

                col.Add(idOut);
            },
                                  returnParameters : delegate(SqlParameterCollection returnCollection)
            {
                object oId = returnCollection["@Id"].Value;

                int.TryParse(oId.ToString(), out id);
            });


            return(id);
        }
コード例 #2
0
 private static void AddCommonParams(TherapistAddRequest model, SqlParameterCollection col, int userId)
 {
     col.AddWithValue("@FirstName", model.FirstName);
     col.AddWithValue("@Email", model.Email);
     col.AddWithValue("@Mi", model.Mi);
     col.AddWithValue("@LastName", model.LastName);
     col.AddWithValue("@AvatarUrl", model.AvatarUrl);
     col.AddWithValue("@Phone", model.Phone);
     col.AddWithValue("@LocationId", model.LocationId);
     col.AddWithValue("@IsActive", model.IsActive);
     col.AddWithValue("@Notes", model.Notes);
     col.AddWithValue("@CreatedBy", userId);
 }