コード例 #1
0
ファイル: BookStoreApi.cs プロジェクト: robb83/Protocols
        public Response InsertBook(Book info)
        {
            if (info == null)
                return Response.GenericError;
            if (String.IsNullOrWhiteSpace(info.Author))
                return Response.GenericError;
            if (String.IsNullOrWhiteSpace(info.ISBN))
                return Response.GenericError;
            if (String.IsNullOrWhiteSpace(info.Publisher))
                return Response.GenericError;
            if (String.IsNullOrWhiteSpace(info.Title))
                return Response.GenericError;

            lock (dataStore)
            {
                Book alreadyExists;
                if (dataStore.TryGetValue(info.ISBN, out alreadyExists))
                {
                    return Response.GenericError;
                }

                dataStore.Add(info.ISBN, info);
            }

            return Response.SuccessResponse;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: robb83/Protocols
        static void DisplayBooks(Book[] books)
        {
            Console.WriteLine("-- Books: ");

            if (books == null || books.Length == 0)
            {
                Console.WriteLine("\tNothing");
                return;
            }

            foreach(Book b in books)
            {
                Console.WriteLine();

                Console.WriteLine("\tISBN: {0} ({1}, {2})", b.ISBN, b.Publisher ,b.PublishYear);
                Console.WriteLine("\tTitle: {0}", b.Title);
                Console.WriteLine("\tAuthor: {0}", b.Author);
            }
        }
コード例 #3
0
 public Response InsertBook(Book book)
 {
     return HttpRequestHelper.HttpPostRequestWithProtoContent<Book, Response>(this.bookStoreRemoteBaseAddress + "/InsertBook", this.proxy, book);
 }