コード例 #1
0
        Task IUserService.ConfirmUserEmail(string userId, string confirmationToken, IValidationErrorNotifier errors)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(userId));
            Contract.Requires(!String.IsNullOrWhiteSpace(confirmationToken));
            Contract.Requires(errors != null);

            throw new NotImplementedException();
        }
コード例 #2
0
        Task IAuctionService.Buyout(int auctionId, string buyerId, IValidationErrorNotifier errors)
        {
            Contract.Requires(auctionId > 0);
            Contract.Requires(buyerId != null);
            Contract.Requires(errors != null);

            throw new NotImplementedException();
        }
コード例 #3
0
        Task IUserService.AddUser(User user, string password, IValidationErrorNotifier errors)
        {
            Contract.Requires(user != null);
            Contract.Requires(password != null);
            Contract.Requires(errors != null);

            throw new NotImplementedException();
        }
コード例 #4
0
        Task IUserService.ResetUserPassword(string userName, string newPassword, string resetToken, IValidationErrorNotifier errors)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(userName));
            Contract.Requires(!String.IsNullOrWhiteSpace(newPassword));
            Contract.Requires(!String.IsNullOrWhiteSpace(resetToken));
            Contract.Requires(errors != null);

            throw new NotImplementedException();
        }
コード例 #5
0
        Task IUserService.UpdateUserPassword(string userId,
		                                     string currentPassword,
		                                     string newPassword,
		                                     IValidationErrorNotifier errors)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(userId));
            Contract.Requires(!String.IsNullOrWhiteSpace(currentPassword));
            Contract.Requires(!String.IsNullOrWhiteSpace(newPassword));
            Contract.Requires(errors != null);

            throw new NotImplementedException();
        }
コード例 #6
0
ファイル: AuctionService.cs プロジェクト: Strachu/Auctioneer
		public async Task MoveAuction(int auctionId, int newCategoryId, string movingUserId, IValidationErrorNotifier errors)
		{
			var auction = await this.GetById(auctionId);
			if(!await CanBeMoved(auction, movingUserId))
			{
				errors.AddError(Lang.Show.CannotMove);
				return;
			}

			auction.CategoryId = newCategoryId;

			await mContext.SaveChangesAsync();
		}
コード例 #7
0
ファイル: AuctionService.cs プロジェクト: Strachu/Auctioneer
		public async Task Buyout(int auctionId, string buyerId, IValidationErrorNotifier errors)
		{
			var auction = await GetById(auctionId);
			if(!auction.IsBuyoutEnabled)
			{
				errors.AddError(Lang.Buy.BuyoutNotEnabled);
				return;
			}

			if(!CanBeBought(auction, buyerId, errors))
				return;
			
			auction.Offers.Add(new BuyOffer
			{
				UserId = buyerId,
				Date   = DateTime.Now,
				Amount = auction.BuyoutPrice.Amount,
			});

			await mContext.SaveChangesAsync();

			await mUserNotifier.NotifyAuctionSold(auction.Seller, auction);
			await mUserNotifier.NotifyAuctionWon(auction.Buyer,   auction);
		}
コード例 #8
0
ファイル: AuctionService.cs プロジェクト: Strachu/Auctioneer
		public async Task Bid(int auctionId, string buyerId, decimal bidAmount, IValidationErrorNotifier errors)
		{
			var auction = await GetById(auctionId);
			if(!auction.IsBiddingEnabled)
			{
				errors.AddError(Lang.Buy.BiddingNotEnabled);
				return;
			}

			if(!CanBeBought(auction, buyerId, errors))
				return;

			if(bidAmount < auction.MinBidAllowed)
			{
				errors.AddError(String.Format(Lang.Buy.TooLowBid, new Money(auction.MinBidAllowed, auction.MinimumPrice.Currency)));
				return;
			}

			var previouslyBestOffer = auction.BestOffer;
			var userOffer           = new BuyOffer
			{
				UserId = buyerId,
				Date   = DateTime.Now,
				Amount = bidAmount,
			};

			auction.Offers.Add(userOffer);

			await mContext.SaveChangesAsync();

			await mUserNotifier.NotifyOfferAdded(userOffer.User, userOffer, auction);

			if(previouslyBestOffer != null)
			{
				await mUserNotifier.NotifyOutbid(previouslyBestOffer.User, auction);
			}
		}
コード例 #9
0
ファイル: AuctionService.cs プロジェクト: Strachu/Auctioneer
		private bool CanBeBought(Auction auction, string buyerId, IValidationErrorNotifier errors)
		{
			if(auction.Status != AuctionStatus.Active)
			{
				errors.AddError(Lang.Buy.AuctionIsInactive);
				return false;
			}

			if(auction.SellerId == buyerId)
			{
				errors.AddError(Lang.Buy.CannotBuyOwnAuctions);
				return false;
			}

			return true;
		}
コード例 #10
0
ファイル: AuctionService.cs プロジェクト: Strachu/Auctioneer
		public async Task RemoveAuctions(IReadOnlyCollection<int> ids, string removingUserId, IValidationErrorNotifier errors)
		{
			var auctions = await mContext.Auctions.Include(x => x.Offers).Where(x => ids.Contains(x.Id)).ToListAsync();
			if(!await auctions.All(async x => await CanBeRemoved(x, removingUserId, errors)))
				return;

			await mContext.Auctions.Where(x => ids.Contains(x.Id)).DeleteAsync();

			foreach(var auctionId in ids)
			{
				RemoveAuctionPhotos(auctionId);
			}
		}
コード例 #11
0
ファイル: AuctionService.cs プロジェクト: Strachu/Auctioneer
		private async Task<bool> CanBeRemoved(Auction auction, string userId, IValidationErrorNotifier errors)
		{
			if(auction.SellerId != userId && !await mUserService.IsUserInRole(userId, "Admin"))
			{
				errors.AddError(Lang.Delete.WrongUser);
				return false;
			}

			if(auction.Offers.Any())
			{
				errors.AddError(Lang.Delete.BuyOfferHasBeenMade);
				return false;				
			}

			if(auction.Status != AuctionStatus.Active)
			{
				errors.AddError(Lang.Delete.AuctionIsInactive);
				return false;
			}

			return true;
		}
コード例 #12
0
        Task IAuctionService.RemoveAuctions(IReadOnlyCollection<int> ids, string removingUserId, IValidationErrorNotifier errors)
        {
            Contract.Requires(removingUserId != null);
            Contract.Requires(ids != null);
            Contract.Requires(errors != null);

            throw new NotImplementedException();
        }
コード例 #13
0
        Task IAuctionService.MoveAuction(int auctionId, int newCategoryId, string movingUserId, IValidationErrorNotifier errors)
        {
            Contract.Requires(auctionId > 0);
            Contract.Requires(newCategoryId > 0);
            Contract.Requires(movingUserId != null);
            Contract.Requires(errors != null);

            throw new NotImplementedException();
        }