Beispiel #1
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     this.Books            = new Books(this);
     this.BorrowedBooks    = new BorrowedBooks(this);
     this.Readers          = new Readers(this);
     this.BaseUri          = new Uri("http://localhost:65040");
     SerializationSettings = new JsonSerializerSettings
     {
         Formatting            = Formatting.Indented,
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
Beispiel #2
0
 /// <summary>
 /// Updates information for an existing reader
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='reader'>
 /// information for the new Reader. The ID should not be set.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <object> PutAsync(this IReaders operations, ReaderModel reader, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.PutWithHttpMessagesAsync(reader, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Get all Readers in the library
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IList <ReaderModel> > GetAllAsync(this IReaders operations, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #4
0
 /// <summary>
 /// Deletes reader from the library
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='readerID'>
 /// The ID of the reader
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <object> DeleteAsync(this IReaders operations, int readerID, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.DeleteWithHttpMessagesAsync(readerID, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #5
0
 /// <summary>
 /// Create a new reader
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='reader'>
 /// information for the new Reader. The ID should not be set.
 /// </param>
 public static object Post(this IReaders operations, ReaderModel reader)
 {
     return(Task.Factory.StartNew(s => ((IReaders)s).PostAsync(reader), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Beispiel #6
0
 /// <summary>
 /// Get all Readers in the library
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static IList <ReaderModel> GetAll(this IReaders operations)
 {
     return(Task.Factory.StartNew(s => ((IReaders)s).GetAllAsync(), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Beispiel #7
0
 /// <summary>
 /// Deletes reader from the library
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='readerID'>
 /// The ID of the reader
 /// </param>
 public static object Delete(this IReaders operations, int readerID)
 {
     return(Task.Factory.StartNew(s => ((IReaders)s).DeleteAsync(readerID), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Beispiel #8
0
 public ReadersController(IReaders readers, UserManager <ApplicationUser> userManager)
 {
     _readers     = readers;
     _userManager = userManager;
 }