public async Task GetAccountAccordingToEmailAsync() { AccountDto Peter; Peter = await accountFacade.GetAccountAccordingToEmailAsync(Konstanty.accountPeter.Email); Assert.AreEqual(Konstanty.guidAccountPeter, Peter.Id); }
public async Task <ActionResult> ChangeEmail(ChangeEmailModel model) { if (model.NewEmail == null || model.NewEmailAgain == null) { return(View(model)); } if (model.NewEmail == model.NewEmailAgain) { var account = await AccountFacade.GetAccountAccordingToEmailAsync(model.Email); if ((await AccountFacade.GetAccountAccordingToEmailAsync(model.NewEmail)) != null) { ModelState.AddModelError("", "Account with this Email already exist"); return(View(new ChangeEmailModel { Email = model.Email })); } account.Email = model.NewEmail; var result = await AccountFacade.EditAccountAsync(account); return(await Login(new LoginModel { EmailAddress = model.NewEmail, Password = account.Password }, null)); } ModelState.AddModelError("", "Entered Emails aren't same"); return(View(new ChangeEmailModel { Email = model.Email })); }
public async Task <ActionResult> Details(string email) { var account = await AccountFacade.GetAccountAccordingToEmailAsync(email); var myAuctions = (await AuctionFacade.GetAllAuctionsForAccount(account.Id)).ToList(); var allMyBids = (await AccountFacade.GetAllBidsAccordingToAccount(account.Id)).ToList(); var biddedAuctions = new List <AuctionDTO>(); foreach (var auction in allMyBids) { biddedAuctions.Add(await AuctionFacade.GetAuctionAsync(auction.AuctionId)); } biddedAuctions = biddedAuctions.Distinct().ToList(); var biddedAuctionsLastBidAccount = new List <Pair <AuctionDTO, AccountDTO> >(); foreach (var auction in biddedAuctions) { biddedAuctionsLastBidAccount.Add(new Pair <AuctionDTO, AccountDTO>(auction, await AccountFacade.GetAccountAccordingToIdAsync( (await AuctionFacade.GetAllBidsAccordingToAuction(auction.Id)).OrderByDescending(x => x.BidDateTime) .First().AccountId))); } AccountDetailModel accountDetailModel = new AccountDetailModel { AccountDto = account, MyAuctions = myAuctions, BiddingAuctionsAndLastBid = new List <Pair <AuctionDTO, AccountDTO> >(biddedAuctionsLastBidAccount) }; return(View("AccountDeatilView", accountDetailModel)); }
public async Task <ActionResult> CreateBid(AuctionDetailViewModel auctionModel) { var accountDto = await AccountFacade.GetAccountAccordingToEmailAsync(auctionModel.EmailOfBidAccount); var result = await AuctionFacade.BidOnAuctionAsync(auctionModel.Id, accountDto.Id, auctionModel.NewBidValue); return(await Details(auctionModel.Id)); }
public async Task <ActionResult> Logout() { var account = await AccountFacade.GetAccountAccordingToEmailAsync(User.Identity.Name); //Response.ClearAllShoppingCartItems(customer.Username); //OrderFacade.ReleaseReservations(customer.Id); FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> Create(AuctionCreateViewModel auctionViewModel) { var account = await AccountFacade.GetAccountAccordingToEmailAsync(auctionViewModel.AccountEmail); var category = await AuctionFacade.GetCategoryAsync(new Guid(auctionViewModel.CategoryId)); var auctionDto = new AuctionDTO() { ClosingTime = auctionViewModel.ClosingTime, ActualPrice = auctionViewModel.ActualPrice, Name = auctionViewModel.Name, Description = auctionViewModel.Description, AccountId = account.Id, IsOpened = true }; await AuctionFacade.CreateAuctionWithCategoryNameAsync(auctionDto, category.Name); return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> ChangePassword(ChangePasswordModel model) { if (model.Password == null || model.PasswordAgain == null) { return(View(model)); } if (model.Password == model.PasswordAgain) { var account = await AccountFacade.GetAccountAccordingToEmailAsync(model.Email); account.Password = model.Password; var result = await AccountFacade.EditAccountAsync(account); return(await Login(new LoginModel { EmailAddress = model.Email, Password = model.Password }, null)); } ModelState.AddModelError("", "Entered Passwords aren't same"); return(View(new ChangePasswordModel { Email = model.Email })); }