コード例 #1
0
        public async Task <ActionResult> AccountDetail(Guid id)
        {
            var result = await AccountFacade.GetAccountAccordingToIdAsync(id);

            var model = await InitializeAccountEditModel(result);

            return(View("AccountEdit", model));
        }
コード例 #2
0
        public async Task <ActionResult> EditAccount(AccountEditModel model)
        {
            var account = await AccountFacade.GetAccountAccordingToIdAsync(model.AccountId);

            account.FirstName         = model.FirstName;
            account.LastName          = model.LastName;
            account.Email             = model.Email;
            account.Password          = model.Password;
            account.Address           = model.Address;
            account.MobilePhoneNumber = model.MobilePhoneNumber;

            await AccountFacade.EditAccountAsync(account);

            return(RedirectToAction("AccountDetail", new { id = model.AccountId }));
        }
コード例 #3
0
        private async Task <AuctionDetailViewModel> InitializeAuctionDetailViewModel(AuctionDTO auction)
        {
            var model = new AuctionDetailViewModel {
                Name = auction.Name
            };
            var result = await AccountFacade.GetAccountAccordingToIdAsync(auction.AccountId);

            model.Bids = new List <Pair <AccountAuctionRelationDTO, AccountDTO> >();
            var bidsList = (await AuctionFacade.GetAllBidsAccordingToAuction(auction.Id)).ToList().OrderBy(x => x.BidDateTime);

            foreach (var bid in bidsList)
            {
                model.Bids.Add(new Pair <AccountAuctionRelationDTO, AccountDTO>(bid, await AccountFacade.GetAccountAccordingToIdAsync(bid.AccountId)));
            }
            model.AccountFullName = result.FirstName + " " + result.LastName;
            model.Description     = auction.Description;
            model.ClosingTime     = auction.ClosingTime;
            var products = await ProductFacade.GetAllProductsInAuction(auction.Id);

            model.Products          = products.ToList();
            model.ActualPrice       = auction.ActualPrice;
            model.IsOpened          = auction.IsOpened;
            model.Id                = auction.Id;
            model.AuctionOwnerEmail = result.Email;
            model.CategoryId        = auction.CategoryId.ToString();
            var categories = await AuctionFacade.GetAllCategories();

            model.CategoriesSelectList = new List <SelectListItem>();
            foreach (var category in categories)
            {
                model.CategoriesSelectList.Add(new SelectListItem {
                    Text = category.Name, Value = category.Id.ToString()
                });
            }


            return(model);
        }
コード例 #4
0
        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));
        }