Пример #1
0
        /// <summary>
        /// After a "Delete" request has been processed and the response basket has ascended to here
        /// any cached object and collection which is now invalid is removed from the cache
        /// </summary>
        /// <param name="basket">The response</param>
        /// <param name="visit">The visit the basket is currently making</param>
        /// <returns>A Task that may be awaited</returns>
        public Task AscendFromAsync(IDeleteBasket <TId> basket, IVisit visit)
        {
            // always remote items from cache on way back up, otherwise another thread
            // may repopulate the cache before the decent is complete
            if (basket.DescentPayload != null)
            {
                Cache.RemoveCollection();
                Cache.Remove(basket.DescentPayload);
            }

            return(Task.CompletedTask);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new BasketService.Presentation.WebApi.Controllers.BasketsController
 /// </summary>
 /// <param name="getAllBaskets">The usecase for getting all customers baskets</param>
 /// <param name="getBasketsById">The usecase for getting a customer basket by id</param>
 /// <param name="insertBasket">The usecase for creating a new basket</param>
 /// <param name="deleteBasket">The usecase for deleting a basket by id</param>
 public BasketsController(
     IGetAllBaskets getAllBaskets,
     IGetBasketsById getBasketsById,
     IInsertBasket insertBasket,
     IDeleteBasket deleteBasket
     )
 {
     this.getAllBaskets  = getAllBaskets;
     this.getBasketsById = getBasketsById;
     this.insertBasket   = insertBasket;
     this.deleteBasket   = deleteBasket;
 }
Пример #3
0
        /// <summary>
        /// Deletes a T from the database and sets the baskets AscentPayload to the number of records affected
        /// </summary>
        /// <param name="basket">A basket</param>
        /// <param name="visit">The visit the basket is currently making</param>
        /// <returns>A Task that may be awaited</returns>
        public async Task AddResultAsync(IDeleteBasket <TId, int> basket, IVisit visit)
        {
            if (basket == null)
            {
                throw new ArgumentNullException(nameof(basket));
            }

            var statement = GetDeleteDbStatement(basket.DescentPayload);

            visit.Log(statement.ToString());

            basket.AscentPayload = await DbInterface.ExecuteNonQueryAsync(statement).ConfigureAwait(false);
        }
Пример #4
0
 /// <summary>
 /// No action performed
 /// </summary>
 /// <param name="basket">The request</param>
 /// <param name="visit">The visit the basket is currently making</param>
 /// <returns>A Task that may be awaited</returns>
 public Task DescendToAsync(IDeleteBasket <TId> basket, IVisit visit)
 {
     return(Task.CompletedTask);
 }
Пример #5
0
        public Task AddResultAsync(IDeleteBasket <int, int> basket, IVisit visit)
        {
            basket.AscentPayload = 1;

            return(Task.CompletedTask);
        }
Пример #6
0
 public Task <IDeleteBasket <TId, int> > SendAsync(IDeleteBasket <TId, int> basket)
 {
     return(new Shaft <IDeleteBasket <TId, int> >(TraceExporter, TerminalLayer, GetStations <IDeleteBasket <TId, int> >())
            .SendAsync(basket));
 }
Пример #7
0
 public Task <IDeleteBasket <int, int> > SendAsync(IDeleteBasket <int, int> basket)
 {
     return(new Shaft <IDeleteBasket <int, int> >(TerminalLayer)
            .Add(CacheLayer)
            .SendAsync(basket));
 }
Пример #8
0
 /// <summary>
 /// Performs no action
 /// </summary>
 /// <param name="basket">A basket</param>
 /// <param name="visit">The visit the basket is currently making</param>
 /// <returns>A Task that may be awaited</returns>
 public Task AscendFromAsync(IDeleteBasket basket, IVisit visit)
 {
     return(Task.CompletedTask);
 }
Пример #9
0
 /// <summary>
 /// If the user is not allowed to "Delete" T's then an UnauthorizedAccessException will be thrown.
 /// </summary>
 /// <param name="basket">The request</param>
 /// <param name="visit">The visit the basket is currently making</param>
 /// <returns>A Task that may be awaited</returns>
 public Task DescendToAsync(IDeleteBasket basket, IVisit visit)
 {
     EnsureOperationAllowed(Operations.Delete, basket, visit);
     return(Task.CompletedTask);
 }