/// <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(); }
/// <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); } }
/// <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); } }
/// <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); } }
/// <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()); }
/// <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()); }
/// <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()); }
public ReadersController(IReaders readers, UserManager <ApplicationUser> userManager) { _readers = readers; _userManager = userManager; }