Updated CatalogItem to support more updates; added tests

This commit is contained in:
Steve Smith
2020-07-03 12:46:33 -04:00
parent 14fbb4284a
commit 2911d5821e
4 changed files with 101 additions and 4 deletions

View File

@@ -1,14 +1,21 @@
namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
using System.ComponentModel.DataAnnotations;
namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
{
public class UpdateCatalogItemRequest : BaseRequest
{
[Range(1, 10000)]
public int Id { get; set; }
[Range(1, 10000)]
public int CatalogBrandId { get; set; }
[Range(1, 10000)]
public int CatalogTypeId { get; set; }
[Required]
public string Description { get; set; }
[Required]
public string Name { get; set; }
public string PictureUri { get; set; }
[Range(0.01, 10000)]
public decimal Price { get; set; }
}
}

View File

@@ -33,7 +33,9 @@ namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
var existingItem = await _itemRepository.GetByIdAsync(request.Id);
existingItem.Update(request.Name, request.Price);
existingItem.UpdateDetails(request.Name, request.Description, request.Price);
existingItem.UpdateBrand(request.CatalogBrandId);
existingItem.UpdateType(request.CatalogTypeId);
await _itemRepository.UpdateAsync(existingItem);