Skip to content

Commit

Permalink
VP-3540: Implement "Remove all quote items" functionality (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyawzrd authored Jul 8, 2020
1 parent c7c85ad commit 6f9d6fa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public interface IQuoteRequestBuilder
/// <returns></returns>
IQuoteRequestBuilder Confirm();

/// <summary>
/// Remove all items from captured RFQ
/// </summary>
/// <returns></returns>
IQuoteRequestBuilder Clear();

/// <summary>
/// Remove item from captured RFQ
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,21 @@ public async Task<ActionResult> RemoveItem(string number, string itemId)
return Ok();
}

// DELETE: storefrontapi/quoterequest/{number}/items
[HttpDelete("quoterequests/{number}/items")]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Clear(string number)
{
await _quoteRequestBuilder.LoadQuoteRequestAsync(number, WorkContext.CurrentLanguage, WorkContext.CurrentCurrency);

using (await AsyncLock.GetLockByKey(GetAsyncLockQuoteKey(_quoteRequestBuilder.QuoteRequest.Id)).LockAsync())
{
_quoteRequestBuilder.Clear();
await _quoteRequestBuilder.SaveAsync();
}
return Ok();
}

// POST: storefrontapi/quoterequest/{number}/submit
[HttpPost("quoterequests/{number}/submit")]
[ValidateAntiForgeryToken]
Expand Down Expand Up @@ -195,7 +210,7 @@ public async Task<ActionResult<QuoteRequestTotals>> CalculateTotals(string numbe
// POST: storefrontapi/quoterequests/{number}/confirm
[HttpPost("quoterequests/{number}/confirm")]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Confirm([FromRoute]string number, [FromBody] QuoteRequestFormModel quoteRequest)
public async Task<ActionResult> Confirm([FromRoute] string number, [FromBody] QuoteRequestFormModel quoteRequest)
{
await _quoteRequestBuilder.LoadQuoteRequestAsync(number, WorkContext.CurrentLanguage, WorkContext.CurrentCurrency);

Expand Down
7 changes: 7 additions & 0 deletions VirtoCommerce.Storefront/Domain/Quote/QuoteRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ public IQuoteRequestBuilder RemoveItem(string quoteItemId)
return this;
}

public IQuoteRequestBuilder Clear()
{
_quoteRequest.Items.Clear();

return this;
}

public IQuoteRequestBuilder Update(QuoteRequestFormModel quoteRequest)
{
QuoteCacheRegion.ExpireQuote(_quoteRequest);
Expand Down

0 comments on commit 6f9d6fa

Please sign in to comment.