コード例 #1
0
        public SuperBeingPowerCreateUpdateDto CreatePower(int SuperBeingId, SuperBeingPowerCreateUpdateDto createPowerDto)
        {
            int returnValue;

            using (SqlConnection con = new SqlConnection(_cs))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("Personnel.PowerAdd", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@RowCount", SqlDbType.Int).Direction = ParameterDirection.Output;
                cmd.Parameters.AddWithValue("@Name", createPowerDto.Name);
                cmd.Parameters.AddWithValue("@Description", createPowerDto.Description);
                cmd.Parameters.AddWithValue("@PowerType", createPowerDto.PowerType);
                cmd.Parameters.AddWithValue("@SuperBeingId", SuperBeingId);

                cmd.ExecuteNonQuery();
                returnValue = Convert.ToInt32(cmd.Parameters["@RowCount"].Value);
            }
            if (returnValue > 0)
            {
                return(createPowerDto);
            }
            else
            {
                throw new Exception("Something went wrong");
            }
        }
コード例 #2
0
        public IActionResult CreateSuperPower(int superBeingId, [FromBody] SuperBeingPowerCreateUpdateDto createDto)
        {
            var newPower = _superBeingRepository.CreatePower(superBeingId, createDto);

            return(NoContent());
        }