public ActionResult Create(NewAuctionViewModel auction) { if (this.ModelState.IsValid) { var members = new SimpleMemberService(this.mainRepository); var newAuction = new Auction() { Title = auction.Title, Description = auction.Description, StartDateTimeUtc = auction.StartDateTimeUtc, EndDateTimeUtc = auction.EndDateTimeUtc, StartPrice = auction.StartPrice, Seller = members.GetCurrentMember() }; // Get File Contents if (auction.Image != null) { byte[] fileContent = new byte[auction.Image.InputStream.Length]; auction.Image.InputStream.Read(fileContent, 0, fileContent.Length); newAuction.Image = fileContent; } this.service.Save(newAuction); AuctionsHub.NotifyNewAuction(newAuction); } return(RedirectToAction("Index")); }
public AuctionsPageController(IAuctionsService auctionsService, ICategoriesService categoriesService, AuctionsHub auctionsHub, ProductService productService) { this.auctionsService = auctionsService; this.categoriesService = categoriesService; this.auctionsHub = auctionsHub; this.productService = productService; }
public ActionResult Create(NewBidViewModel bid) { if (this.ModelState.IsValid) { var auction = this.service.GetAll().FirstOrDefault(a => a.Id == bid.AuctionId); var newBid = this.service.PlaceBid(auction, bid.BidAmount); AuctionsHub.NotifyNewBid(auction, newBid); } return(this.RedirectToAction("Index", "Auctions")); }
public IHttpActionResult PlaceBid(long auctionId, BidDto dto) { var auction = this.repo.GetAuctions().FirstOrDefault(a => a.Id == auctionId); if (auction == null) { return(this.NotFound()); } try { var bid = this.auctionService.PlaceBid(auction, dto.Amount); AuctionsHub.NotifyNewBid(auction, bid); return(this.Created(string.Format("api/bids/{0}", bid.TransactionId), MapBidToDto(bid))); } catch (Exception e) { return(this.BadRequest(e.Message)); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); // DotNetBay startup var mainRepository = new EFMainRepository(); mainRepository.SaveChanges(); // SignalR Configuration var serializerSettings = new JsonSerializerSettings(); serializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize; serializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.Objects; var serializer = JsonSerializer.Create(serializerSettings); GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer); AuctionRunner = new AuctionRunner(mainRepository); AuctionRunner.Auctioneer.BidAccepted += (sender, args) => #pragma warning disable SA1501 // Statement must not be on a single line { AuctionsHub.NotifyBidAccepted(args.Auction, args.Bid); }; AuctionRunner.Auctioneer.BidDeclined += (sender, args) => { AuctionsHub.NotifyBidDeclined(args.Auction, args.Bid); }; AuctionRunner.Auctioneer.AuctionStarted += (sender, args) => { AuctionsHub.NotifyAuctionStarted(args.Auction); }; AuctionRunner.Auctioneer.AuctionEnded += (sender, args) => { AuctionsHub.NotifyAuctionEnded(args.Auction); }; #pragma warning restore SA1501 // Statement must not be on a single line AuctionRunner.Start(); }
public IHttpActionResult AddNewAuction([FromBody] AuctionDto dto) { var theNewAuction = new Auction { Seller = this.memberService.GetCurrentMember(), EndDateTimeUtc = dto.EndDateTimeUtc, StartDateTimeUtc = dto.StartDateTimeUtc, Title = dto.Title, StartPrice = dto.StartPrice }; try { this.auctionService.Save(theNewAuction); AuctionsHub.NotifyNewAuction(theNewAuction); return(this.Created(string.Format("api/auctions/{0}", theNewAuction.Id), this.MapAuctionToDto(theNewAuction))); } catch (Exception e) { return(this.BadRequest(e.Message)); } }