public async Task <IEnumerable <AuctionDto> > GetAuctionsForUser(int userId) { var user = (await UserFacade.GetUserByIdAsync(userId)); var auctions = (await AuctionFacade.GetAuctionsForAuctioner(user)); return(auctions); }
public async Task <ActionResult> EditAuctionInit(AuctionDetailViewModel auctionModel) { var result = await AuctionFacade.GetAuctionAsync(auctionModel.Id); var model = await InitializeAuctionDetailViewModel(result); return(View("AuctionEditView", model)); }
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> Details(Guid id) { var result = await AuctionFacade.GetAuctionAsync(id); var model = await InitializeAuctionDetailViewModel(result); return(View("AuctionDetailView", model)); }
public async Task <IEnumerable <AuctionDto> > GetCurrentAuctions(int id) { var auctions = (await AuctionFacade.GetCurrentAuctionsAsync(DateTime.Now)); foreach (var auction in auctions) { auction.Id = 0; } return(auctions); }
private async Task <AuctionListViewModel> InitializeAuctionListViewModel(QueryResultDto <AuctionDTO, AuctionFilterDto> result, IEnumerable <AuctionDTO> filteredAuctions, int totalItemsCount) { return(new AuctionListViewModel { Auctions = new StaticPagedList <AuctionDTO>(filteredAuctions, result.RequestedPageNumber ?? 1, PageSize, totalItemsCount), Filter = result.Filter, CategoriesSelectList = new List <SelectListItem>((await AuctionFacade.GetAllCategories()).Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() })) }); }
public AdminController(AuctionFacade auctionFacade, UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager, ILogger <RegisterModel> logger, IEmailSender emailSender) { _auctionFacade = auctionFacade; _userManager = userManager; _signInManager = signInManager; _logger = logger; _emailSender = emailSender; }
public async Task <ActionResult> Index(AuctionListViewModel model) { model.Filter.PageSize = PageSize; Session[FilterSessionKey] = model.Filter; var allAuctions = await AuctionFacade.GetAllAuctionsAsync(new AuctionFilterDto()); var result = (await AuctionFacade.GetAllAuctionsAsync(model.Filter)); var filteredAuctions = model.CategoryId != null?result.Items.Where(x => x.CategoryId == new Guid(model.CategoryId)) : result.Items; var newModel = await InitializeAuctionListViewModel(result, filteredAuctions, (int)allAuctions.TotalItemsCount); return(View("AuctionListView", newModel)); }
public void SetUp() { var auctionRespository = new FakeAuctionRepository(); var productRespository = new FakeProductRepository(); productRespository.Add(new AntiqueProduct() { Id = productId }); auctionRespository.AddAuction(new Auction() { Id = auciontId }); sut = new AuctionFacade(auctionRespository, productRespository); }
public async Task <ActionResult> Create() { var categories = await AuctionFacade.GetAllCategories(); var model = new AuctionCreateViewModel(); model.CategoriesSelectList = new List <SelectListItem>(); foreach (var category in categories) { model.CategoriesSelectList.Add(new SelectListItem { Text = category.Name, Value = category.Id.ToString() }); } return(View("AuctionCreateView", model)); }
public async Task <IEnumerable <RaiseDto> > GetRaisesForAuction(int id) { var auction = await AuctionFacade.GetAuctionById(id); if (auction == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } var raises = await AuctionFacade.GetRaisesForAuction(auction); foreach (var raise in raises) { raise.Id = 0; } return(raises); }
public async Task <IEnumerable <ItemDto> > GetItemsForAuction(int id) { var auction = await AuctionFacade.GetAuctionById(id); if (auction == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } var items = await AuctionFacade.GetItemsForAuction(auction); foreach (var item in items) { item.Id = 0; } return(items); }
public async Task <ActionResult> EditAuction(AuctionDetailViewModel auctionModel) { var auctionDto = await AuctionFacade.GetAuctionAsync(auctionModel.Id); auctionDto.CategoryId = new Guid(auctionModel.CategoryId); auctionDto.IsOpened = auctionModel.IsOpened; auctionDto.ClosingTime = auctionModel.ClosingTime; auctionDto.Description = auctionModel.Description; await AuctionFacade.EditAuctionAsync(auctionDto); auctionDto = await AuctionFacade.GetAuctionAsync(auctionModel.Id); auctionModel = await InitializeAuctionDetailViewModel(auctionDto); return(View("AuctionDetailView", auctionModel)); }
public async Task <ActionResult> Index(int page = 1) { var filter = Session[FilterSessionKey] as AuctionFilterDto ?? new AuctionFilterDto { PageSize = PageSize }; filter.RequestedPageNumber = page; //TODO: This is soo much inefficient, why and how could we solve this? var allAuctions = await AuctionFacade.GetAllAuctionsAsync(new AuctionFilterDto()); var result = await AuctionFacade.GetAllAuctionsAsync(filter); var model = await InitializeAuctionListViewModel(result, result.Items, (int)allAuctions.TotalItemsCount); return(View("AuctionListView", model)); }
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 <IEnumerable <AuctionDto> > GetAuctionQuery(string sort = null, bool asc = true, string name = null, int minPrice = 0, int maxPrice = int.MaxValue, [FromUri] CategoryDto[] categories = null) { var filter = new AuctionFilterDto() { SortCriteria = sort, SortAscending = asc, AuctionSearchedName = name, MinimalPrice = minPrice, MaximalPrice = maxPrice, AuctionerID = 0 }; var auctions = (await AuctionFacade.GetFilteredAuctionsAsync(filter)).Items; foreach (var auction in auctions) { auction.Id = 0; } return(auctions); }
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); }
private static void SetUpDatabase() { var db = new EFContext(); var customerFacade = new CustomerFacade(new CustomerRepository(db), new AddressRepository(db), null, new PasswordHandler()); var productRepository = new ProductRepository(db); var productFacade = new ProductFacade(productRepository); var auctionFacade = new AuctionFacade(new AuctionRepository(db), productRepository); var customerId = Guid.NewGuid(); customerFacade.Add(customerId, "Elin", "Danielsson", new List <Address>() { new Address { AddressType = AddressType.Home, City = "Nykvarn", Country = "Sweden", Id = Guid.NewGuid(), PostalCode = "15531", Street = "Skärarevägen 8" } }, "elin", "elin", "*****@*****.**"); var adminId = Guid.NewGuid(); customerFacade.Add(adminId, "Gunnar", "Karlsson", new List <Address>() { new Address { AddressType = AddressType.Work, City = "Stockholm", Country = "Sweden", Id = Guid.NewGuid(), PostalCode = "12345", Street = "Gatan 1" } }, "admin", "admin", "*****@*****.**"); IProductFactory prodcuFactory = new ProductFactory(); Supplier supplier = new Supplier { Id = Guid.NewGuid(), Name = "Elin" }; var product = prodcuFactory.Create(ProductType.Antique, Guid.NewGuid(), "Vas", 22, 300, supplier) as AntiqueProduct; product.TimeEpoch = TimeEpoch.Baroque; Customer customer = customerFacade.Get(customerId); IList <Bid> bids = new List <Bid> { new Bid { Amount = 400, Id = Guid.NewGuid(), Customer = customer, Time = DateTime.Now } }; Auction auction = new Auction() { AcceptedPrice = product.GetStartPrice() * (decimal)1.5, Product = product, Id = Guid.NewGuid(), Bids = bids, StartTime = DateTime.Now.AddHours(-2), EndTime = DateTime.Now.AddDays(7) }; db.Suppliers.Add(supplier); db.AntiqueProducts.Add(product); db.Bids.AddRange(bids); db.Auctions.Add(auction); }
public HomeController(AuctionFacade auctionFacade) { _auctionFacade = auctionFacade; }
public AuctionController(AuctionFacade auctionFacade) { _auctionFacade = auctionFacade; }
public async Task <ActionResult> DeleteAuction(AuctionDetailViewModel model) { await AuctionFacade.DeleteAuctionAsync(model.Id); return(RedirectToAction("Index", "Home")); }