private void OnLoadLeftBatch(object pObjSender, LoadBatchArgs pObjArgs) { if (pObjArgs.Batch != null) { AuctionHeader.SetBatchNumber(pObjArgs.Batch.Number); } }
public AddAttributeSetResponseModel AddAttributeSet(VirtualCardModel virtualCard, AuctionHeaderModel auctionHeader) { AddAttributeSetResponseModel addAttributeSetResponse = default; using (ConsoleCapture capture = new ConsoleCapture()) { try { string loyaltyId = virtualCard?.LOYALTYIDNUMBER ?? string.Empty; AuctionHeader attributeSet = null; if (auctionHeader != null) { attributeSet = new AuctionHeader() { AuctionEventName = auctionHeader.AuctionEventName, AuctionPointType = auctionHeader.AuctionPointType, AuctionTxnType = auctionHeader.AuctionTxnType, CDRewardID = auctionHeader.CDRewardID, HeaderGPRpts = auctionHeader.HeaderGPRpts }; if (virtualCard != null) { attributeSet.AddTransientProperty("VcKey", virtualCard.VCKEY); } } var lwAddAttributeSet = lwSvc.AddAttributeSet(loyaltyId, attributeSet, String.Empty, out double time); if (lwAddAttributeSet != null) { addAttributeSetResponse = new AddAttributeSetResponseModel() { EarnedPoints = lwAddAttributeSet .EarnedPoints .Select(x => new EarnedPointResponseModel() { PointType = x.PointType, PointValue = (decimal)(x.PointValue ?? 0) }) .ToList() }; } } catch (LWClientException ex) { throw new LWServiceException(ex.Message, ex.ErrorCode); } catch (Exception ex) { throw new LWServiceException(ex.Message, -1); } finally { stepContext.AddAttachment(new Attachment("AddAttributeSet", capture.Output, Attachment.Type.Text)); } } return(addAttributeSetResponse); }
private void btnSkip_Click(object pObjSender, RoutedEventArgs pObjArgs) { if (RightBatchForm.Skip()) { AuctionHeader.SetNextBatchNumber(); LeftBatchForm.txtSellerCode.Focus(); } }
private void OnSaveBatch(object pObjSender, SaveBatchArgs pObjArgs) { if (pObjArgs != null) { AuctionHeader.SetNextBatchNumber(); RightBatchForm.Print(pObjArgs.Batch); DisplayInBoardTwo(pObjArgs.Batch); } }
public async Task <IActionResult> Create(AuctionViewModel auction) { var claimsIdentity = (ClaimsIdentity)this.User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); var user = await _db.Seller.Where(s => s.Id == claim.Value).FirstOrDefaultAsync(); if (ModelState.IsValid) { AuctionHeader auctionHeader = new AuctionHeader() { Seen = false, SellerId = claim.Value, User = user, BeginDate = auction.AuctionHeader.BeginDate, EndDate = auction.AuctionHeader.EndDate, CurrentPrice = auction.AuctionHeader.CurrentPrice, PriceStep = auction.AuctionHeader.PriceStep }; _db.AuctionHeader.Add(auctionHeader); await _db.SaveChangesAsync(); foreach (var item in auction.Products) { var productSale = await _db.ProductSale.Include(p => p.Product).Where(p => p.Id == item.ProductSale.Id).FirstOrDefaultAsync(); productSale.Units -= item.Quantity; var product = await _db.Product.Where(p => p.Id == productSale.ProductId).FirstOrDefaultAsync(); var auctionProduct = new AuctionProduct() { ProductId = product.Id, Product = product, AuctionId = auctionHeader.Id, AuctionHeader = auctionHeader, Quantity = item.Quantity }; _db.AuctionProduct.Add(auctionProduct); } await _db.SaveChangesAsync(); return(RedirectToAction("Index", "Seller")); } foreach (var modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { Console.WriteLine(error.ErrorMessage); } } return(RedirectToAction(nameof(Select))); }
private async void Close(AuctionHeader auction) { var winner = await _db.AuctionUser.FirstOrDefaultAsync(u => u.AuctionId == auction.Id && u.LastPriceOffered == auction.CurrentPrice); if (winner == null) { var aproducts = await _db.AuctionProduct.Where(p => p.AuctionId == auction.Id).ToListAsync(); foreach (AuctionProduct ap in aproducts) { ProductSale psale = await _db.ProductSale.Where(ps => ps.ProductId == ap.ProductId && ps.SellerId == auction.SellerId).FirstOrDefaultAsync(); if (psale != null) { psale.Units += ap.Quantity; _db.ProductSale.Update(psale); } } await NotiApi.SendNotiAuction(_db, "Your auction was succefully ignored", auction.SellerId, auction.Id); auction.Seen = true; _db.AuctionHeader.Update(auction); } else { //winner await NotiApi.SendNotiAuction(_db, "Congrats! You win the auction " + auction.Id.ToString() + ".", winner.UserId, auction.Id); await NotiApi.SendNotiAuction(_db, "Your auction was succefully closed, end value was of $" + auction.CurrentPrice.ToString("F2"), auction.SellerId, auction.Id); //Sending Notificaiton to all the losers var losers = await _db.AuctionUser.Where(u => u.AuctionId == auction.Id && u.LastPriceOffered < auction.CurrentPrice).ToListAsync(); foreach (var l in losers) { await NotiApi.SendNotiAuction(_db, "You lose the auction " + auction.Id.ToString() + ".", l.UserId, auction.Id); } auction.Seen = true; _db.AuctionHeader.Update(auction); } // _db.AuctionHeader.Remove(auction); _db.SaveChanges(); }
private void OnEditBatch(object pObjSender, EditBatchArgs pObjArgs) { if (pObjArgs.Batch != null) { AuctionHeader.SetEditionBatchNumber(pObjArgs.Batch.Number); //AuctionHeader.txtBatch.Text = pObjArgs.Batch.Number.ToString(); RightBatchForm.EnableForm(); RightBatchForm.SetBatchObject(pObjArgs.Batch, true); RightBatchForm.UpdateFormMode(FormModeEnum.EDIT); //Enable buttons btnSave.IsEnabled = true; btnPrint.IsEnabled = true; btnUndo.IsEnabled = false; } else { //Disable buttons btnSave.IsEnabled = false; btnPrint.IsEnabled = false; btnUndo.IsEnabled = false; } }
private void OnConfirmBatch(object pObjSender, ConfirmBatchArgs pObjArgs) { if (pObjArgs.Batch != null) { AuctionHeader.SetNextBatchNumber(); DisplayInBoardOne(pObjArgs.Batch); LeftBatchForm.EnableForm(); RightBatchForm.EnableForm(); RightBatchForm.SetBatchObject(pObjArgs.Batch); RightBatchForm.UpdateFormMode(FormModeEnum.NEW); //Enable buttons btnSave.IsEnabled = true; btnPrint.IsEnabled = true; btnUndo.IsEnabled = true; } else { //Disable buttons btnSave.IsEnabled = false; btnPrint.IsEnabled = false; btnUndo.IsEnabled = false; } }
protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity <NotiBuy>() .HasMany(n => n.OrderDetails) .WithOne() .OnDelete(DeleteBehavior.SetNull); modelBuilder.Entity <NotiSell>() .HasMany(n => n.OrderDetails) .WithOne() .OnDelete(DeleteBehavior.SetNull); #region *******************Seeding Data******************* for (int i = 1; i <= 10; i++) { //Seeding 10 products... modelBuilder.Entity <Product>() .HasData(new Product() { Id = i * 10, Name = "Producto" + i.ToString(), Description = "Descripcion del producto" + i.ToString() }); //Seeding 10 users(customers) RegisterUser(modelBuilder, (i * 10 + 1).ToString(), SD.CustomerUser, "Customer" + i.ToString()); //Seeding 10 seller RegisterSeller(modelBuilder, (i * 10 + 2).ToString(), SD.SellerUser, "Seller" + i.ToString()); //Seeding 10 products sales modelBuilder.Entity <ProductSale>() .HasData(new ProductSale() { Id = i * 1000 + 3, ProductId = i * 10, SellerId = (i * 10 + 2).ToString(), Units = i + 1, Price = (i + 15) / 2, Image = @"/images/default.png" }); //Seeding Notifications of Role Upgrade if (i % 3 == 0) { modelBuilder.Entity <NotiRole>() .HasData(new NotiRole() { Id = i * 10 + 4, UserID = (i * 10 + 1).ToString(), Message = "Customer" + i.ToString() + " wants to become a Seller", SendToUser = "******", Seen = false }); } //Seeding Auctions if (i % 2 != 0) { AuctionHeader ah; if (i == 3 || i == 5) // Seeding two Ended Auctions { ah = new AuctionHeader() { BeginDate = DateTime.Now, CurrentPrice = i + 3, EndDate = DateTime.Now, Id = i * 10 + 5, PriceStep = i, SellerId = (i * 10 + 2).ToString() }; } else if (i == 1) //Seeding an upcoming auction { ah = new AuctionHeader() { BeginDate = DateTime.Now.AddHours(5), CurrentPrice = i, EndDate = DateTime.Now.AddHours(i + 10), Id = i * 10 + 5, PriceStep = i, SellerId = (i * 10 + 2).ToString() }; } else { ah = new AuctionHeader() { BeginDate = DateTime.Now, CurrentPrice = i + 3, EndDate = DateTime.Now.AddHours(i + 10), Id = i * 10 + 5, PriceStep = i, SellerId = (i * 10 + 2).ToString() }; } var ap = new AuctionProduct() { AuctionId = i * 10 + 5, Id = i * 10 + 6, ProductId = i * 10, Quantity = (i + 1) / 2, }; var ap1 = new AuctionProduct() { AuctionId = i * 10 + 5, Id = i * 100000 + 6, ProductId = (i + 1) * 10, Quantity = (i + 1) / 2, }; if (i != 5 && i != 1) // The auction 5 and 1 does not contain an auctionUser { if (i == 3) // Auction 3 has two auctionUser { var auser2 = new AuctionUser() { Id = i * 10000000 + 7, AuctionId = i * 10 + 5, UserId = ((i + 1) * 10 + 1).ToString(), LastPriceOffered = i + 1 }; modelBuilder.Entity <AuctionUser>() .HasData(auser2); } var auser = new AuctionUser() { Id = i * 10 + 7, AuctionId = i * 10 + 5, UserId = (i * 10 + 1).ToString(), LastPriceOffered = i + 3 }; modelBuilder.Entity <AuctionUser>() .HasData(auser); } modelBuilder.Entity <AuctionHeader>() .HasData(ah); modelBuilder.Entity <AuctionProduct>() .HasData(ap); modelBuilder.Entity <AuctionProduct>() .HasData(ap1); } } //Adding just one more product sale, Seller 8 is selling product 1 modelBuilder.Entity <ProductSale>() .HasData(new ProductSale() { Id = 8 * 10000 + 3, ProductId = 1 * 10, SellerId = (8 * 10 + 2).ToString(), Units = 8 + 1, Price = (8 + 15) / 2 }); //Defining Roles string [] roles = { SD.CustomerUser, SD.ManagerUser, SD.SellerUser }; foreach (var role in roles) { modelBuilder.Entity <IdentityRole>().HasData(new IdentityRole() { Id = "a18be9c0" + role, Name = role, NormalizedName = role }); } //Adding an Admin RegisterSeller(modelBuilder, "21123111111", SD.ManagerUser, "admin"); #endregion }