예제 #1
0
        public int Insert(StrengthProfileInsertRequest req)
        {
            int id = 0;

            using (SqlConnection con = new SqlConnection(connString))
            {
                SqlCommand cmd = new SqlCommand("dbo.StrengthProfile_Insert", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter outputParam = cmd.Parameters.Add("@Id", SqlDbType.Int);
                outputParam.Direction = ParameterDirection.Output;

                cmd.Parameters.AddWithValue("@UserId", req.UserId);
                cmd.Parameters.AddWithValue("@Weight", req.Weight);
                cmd.Parameters.AddWithValue("@BenchMax", req.BenchMax);
                cmd.Parameters.AddWithValue("@DeadliftMax", req.DeadliftMax);
                cmd.Parameters.AddWithValue("@SquatMax", req.SquatMax);
                cmd.Parameters.AddWithValue("@ShoulderPressMax", req.ShoulderPressMax);

                con.Open();
                cmd.ExecuteNonQuery();
                id = int.Parse(outputParam.Value.ToString());
                con.Close();
            }
            return(id);
        }
예제 #2
0
        public ActionResult <ItemResponse <int> > Insert(StrengthProfileInsertRequest req)
        {
            ItemResponse <int> response = null;
            ActionResult       result   = null;

            try
            {
                int id = _strengthProfileService.Insert(req);

                if (id > 0)
                {
                    response      = new ItemResponse <int>();
                    response.Item = id;

                    result = Created201(response);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                result = StatusCode(500, new ErrorResponse(ex.Message.ToString()));
            }
            return(result);
        }