示例#1
0
 public bool UserHasOrder(User user, ContentPackage package)
 {
     var profileService = new ProfileService(UnitOfWork);
     var profile = profileService.GetUserProfile(user);
     var order = UnitOfWork.GetRepository<Order>().Get(o => o.ContentPackage.ID == package.ID
                                                     && o.UserProfile.ID == profile.ID)
         .FirstOrDefault();
     return order != null;
 }
示例#2
0
        public void MakeOrder(Order order)
        {
            UnitOfWork.GetRepository<Order>().Insert(order);
            var price = order.ContentPackage.Price;

            var profileService = new ProfileService(UnitOfWork);
            var ownerProfile = profileService.GetUserProfile(order.ContentPackage.Owner);

            order.UserProfile.Balance -= price;
            ownerProfile.Balance += price;

            UnitOfWork.Save();
        }