public void Add(int knifeId, int userId) { var knife = _unitOfWork.KnifeRepository.Get(x => x.Id == knifeId); if (GetAll().Count == 0) { var check = new Check() { Date = DateTime.Now, Id = CartId, Status = CheckStatus.InBasket, Sum = knife.Price, UserId = userId }; var sell = new Sell() { Check = check, CheckId = check.Id, KnifeId = knifeId, Quantity = 1, Knife = knife }; _unitOfWork.CheckRepository.Insert(check); _unitOfWork.SellRepository.Insert(sell); _unitOfWork.Save(); } var mapped = _mapper.Map <Knife, KnifeDTO>(knife); _cart.Add(mapped); BasketChanged?.Invoke(this, new EventArgs()); }
public void Remove(int knifeId) { var knife = _unitOfWork.KnifeRepository.Get(x => x.Id == knifeId); var mapped = _mapper.Map <Knife, KnifeDTO>(knife); _cart.Remove(mapped); BasketChanged?.Invoke(this, new EventArgs()); }
public void UseDiscount(IDiscount discount) { _cart.UseDiscount(discount); BasketChanged?.Invoke(this, new EventArgs()); }
public void Clear() { _cart.Clear(); BasketChanged?.Invoke(this, new EventArgs()); }