/// <summary> /// /// </summary> /// <param name="register"></param> /// <param name="token"></param> /// <returns></returns> public async Task <int> CreateAsync(Product register, CancellationTokenSource token) { B2CProduct newProduct = register.AdapterProduct(); newProduct.IsActive = true; var result = await Repository.CreateAsync(newProduct, token); if (register.Images != null && register.Images.Any()) { await ServiceImage.CreateAsync(register.Images, result, token); } return(result); }
public async Task <bool> Update(Product product, CancellationTokenSource token) { bool exists = await Repository.ExistAsync(product.Id, token); if (exists) { B2CProduct updateProduct = product.AdapterProduct(); var result = await Repository.UpdateAsync(updateProduct, token); if (product.Images != null && product.Images.Any()) { await ServiceImage.UpdateAsync(product.Images, token); } return(result); } else { string msg = String.Format(MessagesApplication.NotFoundCode, product.Id); throw new BussinesException(msg, null); } }