public void MakePurchase(ICollection <MContainer> containers, User customer) { var totalCost = containers.Select(c => c.Eat.Price).Sum(); customer.Money -= totalCost; _userRepository.Update(customer); containers.ToList().ForEach(c => _receiptRepository.Add(new Receipt { User = customer, Container = c })); var emptyContainers = containers.Select(c => { c.IsDeleted = true; c.ReadyForOpen = true; return(c); }).ToList(); emptyContainers.ForEach(ec => _machineContainerRepository.Update(ec)); }
public void AddMoney(User model, decimal money) { model.Money += money; _userRepository.Update(model); }