Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
 public Response InsertBook(Book book)
 {
     return HttpRequestHelper.HttpPostRequestWithProtoContent<Book, Response>(this.bookStoreRemoteBaseAddress + "/InsertBook", this.proxy, book);
 }