Пример #1
0
        public Author AddAuthor(Author author)
        {
            author.Id = Guid.NewGuid();
            using (var connection = _connector.GetSqlConnection())
            {
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = @"spAddAuthor";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@authorId", author.Id);
                    cmd.Parameters.AddWithValue("@firstName", author.FirstName);
                    cmd.Parameters.AddWithValue("@lastName", author.LastName);
                    cmd.Parameters.AddWithValue("@genre", author.Genre);
                    cmd.Parameters.AddWithValue("@dateOfBirth", author.DateOfBirth);

                    cmd.ExecuteNonQuery();
                }
            }
            return(author);
        }