Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VP-3540: Implement "Remove all quote items" functionality #466

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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