public IActionResult Get([FromRoute] int event_id, [FromRoute] int sold_item_id) { Events e = db.Events.Where(r => r.Id == event_id).FirstOrDefault(); if (e == null) { return(StatusCode(404, ErrorMessageHelper.GenerateResponse(404, "Event not found"))); } SoldItems s = db.SoldItems.Where(r => r.EventId == event_id && r.Id == sold_item_id).FirstOrDefault(); if (s == null) { return(StatusCode(404, ErrorMessageHelper.GenerateResponse(404, "Sold Item not found"))); } if (!(DateTime.Now >= e.EndTime)) { return(StatusCode(400, ErrorMessageHelper.GenerateResponse(400, "Event is not yet complete to generate the winning bid"))); } List <Bids> b_l = db.Bids.Where(r => r.SoldItemId == s.Id).ToList(); int winning_bid = (b_l.Count == 0) ? 0 : WinningBidService.GenerateWinningBid(b_l, s); return(Ok(new JObject { { "winning_bid", winning_bid } })); }
public static float GenerateWinningBid(List <Bids> b_l, SoldItems s) { IDictionary <int, float> current_user_bids = new Dictionary <int, float>(); float current_item_bid = s.BasePrice; float current_user_bid; foreach (Bids b in b_l) { if (current_user_bids.TryGetValue(b.UserId, out current_user_bid)) { if (current_user_bid > current_item_bid && current_user_bid <= s.IncrementLimit) { current_item_bid = current_user_bid; } else if (current_item_bid > current_user_bid && current_user_bid + b.IncrementAmount <= s.IncrementLimit && current_user_bid + b.IncrementAmount <= b.MaxBid) { current_user_bid = current_user_bid + b.IncrementAmount; current_item_bid = current_user_bid; current_user_bids[b.UserId] = current_user_bid; } } else if (b.StartBid < s.IncrementLimit && b.StartBid <= b.MaxBid) { current_user_bids.Add(b.UserId, b.StartBid); } } return(current_item_bid); }
public void SellItems(List <SoldItem> itemsToSell) { // Check all the prices before starting the transaction // to make sure the modifiers stay the same for the whole transaction Dictionary <ItemPrefab, int> sellValues = GetSellValuesAtCurrentLocation(itemsToSell.Select(i => i.ItemPrefab)); var canAddToRemoveQueue = (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer) && Entity.Spawner != null; foreach (SoldItem item in itemsToSell) { var itemValue = sellValues[item.ItemPrefab]; // check if the store can afford the item and if the item hasn't been removed already if (Location.StoreCurrentBalance < itemValue || item.Removed) { continue; } if (!item.Removed && canAddToRemoveQueue && Entity.FindEntityByID(item.ID) is Item entity) { item.Removed = true; Entity.Spawner.AddToRemoveQueue(entity); } SoldItems.Add(item); Location.StoreCurrentBalance -= itemValue; campaign.Money += itemValue; } OnSoldItemsChanged?.Invoke(); }
public string InsertClientDetail(SoldItems ObjSoldItems) { string ResultSet = null; DbParam[] param = new DbParam[] { new DbParam(ObjSoldItems.AdharNumber, typeof(System.String), "_AdharNumber"), new DbParam(ObjSoldItems.PersonName, typeof(System.String), "_PersonName"), new DbParam(ObjSoldItems.ShopName, typeof(System.String), "_ShopName"), new DbParam(ObjSoldItems.BankName, typeof(System.String), "_BankName"), new DbParam(ObjSoldItems.AccountNo, typeof(System.String), "_AccountNo"), new DbParam(ObjSoldItems.IFSCCode, typeof(System.String), "_IFSCCode"), new DbParam(ObjSoldItems.GSTIN, typeof(System.String), "_GSTIN"), new DbParam(ObjSoldItems.FullAddress, typeof(System.String), "_FullAddress"), new DbParam(ObjSoldItems.Mobile, typeof(System.String), "_Mobile"), new DbParam(ObjSoldItems.Email, typeof(System.String), "_Email"), new DbParam(ObjSoldItems.ExistingClientUid, typeof(System.String), "_ExistingClientUid"), new DbParam(ObjSoldItems.FileName, typeof(System.String), "_FileName"), new DbParam(DateTime.Now, typeof(System.DateTime), "_OrderedDate"), new DbParam(ObjSoldItems.NewShippingAddress, typeof(System.String), "_NewShippingAddress"), new DbParam(ObjSoldItems.AddressUniqueCode, typeof(System.String), "_AddressUniqueCode"), new DbParam(ObjSoldItems.PaymentMode, typeof(System.String), "_PaymentMode"), new DbParam(ObjSoldItems.GuestUserName, typeof(System.String), "_GuestUserName"), new DbParam(ObjSoldItems.PaymentType, typeof(System.String), "_PaymentType"), new DbParam(ObjSoldItems.Latitude, typeof(System.String), "_Latitude"), new DbParam(ObjSoldItems.Longitude, typeof(System.String), "_Longitude"), new DbParam(ObjSoldItems.Mihpayid, typeof(System.String), "_Mihpayid"), new DbParam(ObjSoldItems.BankStatus, typeof(System.String), "_BankStatus"), new DbParam(ObjSoldItems.UnmappedStatus, typeof(System.String), "_UnmappedStatus"), new DbParam(ObjSoldItems.OrderStatus, typeof(System.String), "_OrderStatus"), new DbParam(ObjSoldItems.GoodsAsXml, typeof(System.String), "_GoodsAsXml") }; db.ExecuteNonQuery("", param, false); return(ResultSet); }
protected override void UpdateContent() { AllItems.Clear(); IList <Item> all_items = FindAllItems(mSearchField, mSearchValue); foreach (Item item in all_items) { AllItems.Add(item); } SoldItems.Clear(); IList <Item> sold_items = FindSoldItems(mSearchField, mSearchValue); foreach (Item item in sold_items) { SoldItems.Add(item); } BoughtItems.Clear(); IList <Item> bought_items = FindBoughtItems(mSearchField, mSearchValue); foreach (Item item in bought_items) { BoughtItems.Add(item); } InventoriedItems.Clear(); IList <Item> inventoried_items = FindInventoriedItems(mSearchField, mSearchValue); foreach (Item item in inventoried_items) { InventoriedItems.Add(item); } }
public void SellItems(List <SoldItem> itemsToSell) { var canAddToRemoveQueue = (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer) && Entity.Spawner != null; foreach (SoldItem item in itemsToSell) { var itemValue = GetSellValueAtCurrentLocation(item.ItemPrefab); // check if the store can afford the item and if the item hasn't been removed already if (location.StoreCurrentBalance < itemValue || item.Removed) { continue; } if (!item.Removed && canAddToRemoveQueue && Entity.FindEntityByID(item.ID) is Item entity) { item.Removed = true; Entity.Spawner.AddToRemoveQueue(entity); } SoldItems.Add(item); location.StoreCurrentBalance -= itemValue; campaign.Money += itemValue; } OnSoldItemsChanged?.Invoke(); }
public ActionResult AddProductToSaleInvoice(Models.Saledto saleproduct) { var product = productprovider.GetById(saleproduct.ProductId); SoldItems soldItems = new SoldItems { ProductId = product.Id, UnitPrice = saleproduct.UnitPrice, Quantity = saleproduct.Quantity }; List <SoldItems> soldproductlist = new List <SoldItems>(); var soldproducts = Session["soldproductlist"] as List <SoldItems>; if (soldproducts == null) { soldproductlist.Add(soldItems); Session["soldproductlist"] = soldproductlist; } else { soldproducts.Add(soldItems); Session["soldproductlist"] = soldproducts; } return(RedirectToAction("GetProductToSale")); }
public void SellItems(List <PurchasedItem> itemsToSell) { var itemsInInventory = GetSellableItems(Character.Controlled); var canAddToRemoveQueue = campaign.IsSinglePlayer && Entity.Spawner != null; var sellerId = GameMain.Client?.ID ?? 0; foreach (PurchasedItem item in itemsToSell) { var itemValue = GetSellValueAtCurrentLocation(item.ItemPrefab, quantity: item.Quantity); // check if the store can afford the item if (Location.StoreCurrentBalance < itemValue) { continue; } var matchingItems = itemsInInventory.FindAll(i => i.Prefab == item.ItemPrefab); if (matchingItems.Count <= item.Quantity) { foreach (Item i in matchingItems) { SoldItems.Add(new SoldItem(i.Prefab, i.ID, canAddToRemoveQueue, sellerId)); SoldEntities.Add(campaign.IsSinglePlayer ? SoldEntity.CreateInSinglePlayer(i) : SoldEntity.CreateInMultiPlayer(i)); if (canAddToRemoveQueue) { Entity.Spawner.AddToRemoveQueue(i); } } } else { for (int i = 0; i < item.Quantity; i++) { var matchingItem = matchingItems[i]; SoldItems.Add(new SoldItem(matchingItem.Prefab, matchingItem.ID, canAddToRemoveQueue, sellerId)); SoldEntities.Add(campaign.IsSinglePlayer ? SoldEntity.CreateInSinglePlayer(matchingItem) : SoldEntity.CreateInMultiPlayer(matchingItem)); if (canAddToRemoveQueue) { Entity.Spawner.AddToRemoveQueue(matchingItem); } } } // Exchange money Location.StoreCurrentBalance -= itemValue; campaign.Money += itemValue; // Remove from the sell crate if (ItemsInSellCrate.Find(pi => pi.ItemPrefab == item.ItemPrefab) is { } itemToSell) { itemToSell.Quantity -= item.Quantity; if (itemToSell.Quantity < 1) { ItemsInSellCrate.Remove(itemToSell); } } } OnSoldItemsChanged?.Invoke(); }
public IResponse <ApiResponse> SoldGoods(SoldItems ObjSoldItems) { PayUResponse ObjPayUResponse = null; string TxnUid = null; ObjPayUResponse = new PayUResponse(); TxnUid = accountService.TransactionIdExists(ObjSoldItems.ExistingClientUid, null, 3); if (TxnUid != null) { ObjSoldItems.TxnUid = TxnUid; ObjSoldItems.TxnIdExists = 1; } else { ObjSoldItems.TxnIdExists = 0; TxnUid = accountService.Generatetxnid(); ObjSoldItems = sellGoodService.SoldGoodsService(ObjSoldItems); ObjPayUResponse = new PayUResponse(); ObjPayUResponse.txnid = TxnUid; ObjSoldItems.TxnUid = TxnUid; ObjPayUResponse.amount = ObjSoldItems.TotalAmount.ToString(); string PaymentStatus = accountService.InsertPaymentInformation(ObjPayUResponse, null, 2018, ObjSoldItems.ExistingClientUid, 3, 0, 0); } ObjSoldItems.ObjClientDetail = sellGoodService.GetClientDetailByUid(ObjSoldItems.ExistingClientUid); return(null);// context.Stringify(ObjSoldItems); }
public ActionResult <SoldItems> AddBadSeller([FromBody] SoldItems badSeller) { if (ebayDBRecords.AddBadSeller(badSeller)) { return(badSeller); } return(null); }
// FIXME - error handling + validator public bool AddBadSeller(SoldItems badSeller) { if (badSeller != null) { db.SoldItems.Add(badSeller); db.SaveChanges(); return(true); } return(false); }
public SoldItems SoldGoodsService(SoldItems ObjSoldItems) { if (!string.IsNullOrEmpty(ObjSoldItems.ExistingClientUid)) { Clients ObjClients = GetClientDetailByUid(ObjSoldItems.ExistingClientUid); ObjSoldItems.Mobile = ObjClients.Mobile; ObjSoldItems.Email = ObjClients.Email; ObjSoldItems.PersonName = ObjClients.PersonName; } return(ObjSoldItems); }
public void BuyBackSoldItems(List <SoldItem> itemsToBuy) { foreach (SoldItem item in itemsToBuy) { var itemValue = GetSellValueAtCurrentLocation(item.ItemPrefab); if (location.StoreCurrentBalance < itemValue || item.Removed) { continue; } location.StoreCurrentBalance += itemValue; campaign.Money -= itemValue; SoldItems.Remove(item); } }
public IResponse <ApiResponse> VerifyNGetPartial(SoldItems ObjSoldItems, string ClientViewName) { //string View = ClientViewName.ToLower(); //switch (View) //{ // case "default": // var Data = SoldGoods(ObjSoldItems); // if (string.IsNullOrEmpty(Data)) // ViewBag.PartialViewData = "nil"; // else // ViewBag.PartialViewData = Data; // return PartialView("_DefaultBillLayout"); // default: return null; //} return(null); }
public void BuyBackSoldItems(List <SoldItem> itemsToBuy) { // Check all the prices before starting the transaction // to make sure the modifiers stay the same for the whole transaction Dictionary <ItemPrefab, int> sellValues = GetSellValuesAtCurrentLocation(itemsToBuy.Select(i => i.ItemPrefab)); foreach (SoldItem item in itemsToBuy) { var itemValue = sellValues[item.ItemPrefab]; if (Location.StoreCurrentBalance < itemValue || item.Removed) { continue; } Location.StoreCurrentBalance += itemValue; campaign.Money -= itemValue; SoldItems.Remove(item); } }
public void SetSoldItems(List <SoldItem> items) { SoldItems.Clear(); SoldItems.AddRange(items); foreach (SoldEntity se in SoldEntities) { if (se.Status == SoldEntity.SellStatus.Confirmed) { continue; } if (SoldItems.Any(si => si.ID == se.Item.ID && si.ItemPrefab == se.Item.Prefab && (GameMain.Client == null || GameMain.Client.ID == si.SellerID))) { se.Status = SoldEntity.SellStatus.Confirmed; } else { se.Status = SoldEntity.SellStatus.Unconfirmed; } } OnSoldItemsChanged?.Invoke(); }
public IActionResult Post([FromRoute] int event_id, [FromRoute] int sold_item_id, [FromBody] BidRequestRoot b_r) { //could avoid redundancy in this check Events e = db.Events.Where(r => r.Id == event_id).FirstOrDefault(); if (e == null) { return(StatusCode(404, ErrorMessageHelper.GenerateResponse(404, "Event not found"))); } SoldItems s = db.SoldItems.Where(r => r.EventId == event_id && r.Id == sold_item_id).FirstOrDefault(); if (s == null) { return(StatusCode(404, ErrorMessageHelper.GenerateResponse(404, "Sold Item not found"))); } if (!(DateTime.Now >= e.StartTime && DateTime.Now <= e.EndTime)) { return(StatusCode(400, ErrorMessageHelper.GenerateResponse(400, "Event is not active to receive bids"))); } Bids previous_bid = db.Bids.Where(r => r.SoldItemId == s.Id).FirstOrDefault(); if (previous_bid != null) { return(StatusCode(400, ErrorMessageHelper.GenerateResponse(400, "Bid found already"))); } Bids b = b_r.createBid(s.Id); db.Bids.Add(b); db.SaveChanges(); return(Ok(new JObject { { "success", true } })); }
public void ClearSoldItemsProjSpecific() { SoldItems.Clear(); }
public void SellItems(List <PurchasedItem> itemsToSell) { var itemsInInventory = GetSellableItems(Character.Controlled); var canAddToRemoveQueue = campaign.IsSinglePlayer && Entity.Spawner != null; var sellerId = GameMain.Client?.ID ?? 0; // Check all the prices before starting the transaction // to make sure the modifiers stay the same for the whole transaction Dictionary <ItemPrefab, int> sellValues = GetSellValuesAtCurrentLocation(itemsToSell.Select(i => i.ItemPrefab)); foreach (PurchasedItem item in itemsToSell) { var itemValue = item.Quantity * sellValues[item.ItemPrefab]; // check if the store can afford the item if (Location.StoreCurrentBalance < itemValue) { continue; } // TODO: Write logic for prioritizing certain items over others (e.g. lone Battery Cell should be preferred over one inside a Stun Baton) var matchingItems = itemsInInventory.Where(i => i.Prefab == item.ItemPrefab); if (matchingItems.Count() <= item.Quantity) { foreach (Item i in matchingItems) { SoldItems.Add(new SoldItem(i.Prefab, i.ID, canAddToRemoveQueue, sellerId)); SoldEntities.Add(campaign.IsSinglePlayer ? SoldEntity.CreateInSinglePlayer(i) : SoldEntity.CreateInMultiPlayer(i)); if (canAddToRemoveQueue) { Entity.Spawner.AddToRemoveQueue(i); } } } else { for (int i = 0; i < item.Quantity; i++) { var matchingItem = matchingItems.ElementAt(i); SoldItems.Add(new SoldItem(matchingItem.Prefab, matchingItem.ID, canAddToRemoveQueue, sellerId)); SoldEntities.Add(campaign.IsSinglePlayer ? SoldEntity.CreateInSinglePlayer(matchingItem) : SoldEntity.CreateInMultiPlayer(matchingItem)); if (canAddToRemoveQueue) { Entity.Spawner.AddToRemoveQueue(matchingItem); } } } // Exchange money Location.StoreCurrentBalance -= itemValue; campaign.Money += itemValue; // Remove from the sell crate if (ItemsInSellCrate.Find(pi => pi.ItemPrefab == item.ItemPrefab) is { } itemToSell) { itemToSell.Quantity -= item.Quantity; if (itemToSell.Quantity < 1) { ItemsInSellCrate.Remove(itemToSell); } } } OnSoldItemsChanged?.Invoke(); }
public void OpenPayUMoneyForClient(FormCollection FormData) { SoldItems ObjSoldItems = null; Clients ObjClient = null; //if (FormData["formcollectionData"] != null && FormData["formcollectionData"] != "") //{ // ObjSoldItems = context.Parse<SoldItems>(FormData["formcollectionData"]); // if (ObjSoldItems != null && ObjSoldItems.TxnUid != "") // { // if (ObjSoldItems.TxnIdExists == 1) // { // ObjClient = sellGoodService.GetClientDetailByUid(ObjSoldItems.ExistingClientUid); // if (ObjClient != null) // { // ObjSoldItems.Mobile = ObjClient.Mobile; // ObjSoldItems.Email = ObjClient.Email; // ObjSoldItems.PersonName = ObjClient.PersonName; // ObjSoldItems.PayeeCode = 3; // } // else // { // // unable to get parent detail // } // } // string MarchandKey = context.GetWebConfigAppSettingValue("MarchandKey"); // string Salt = context.GetWebConfigAppSettingValue("Salt"); // string ServiceProvider = context.GetWebConfigAppSettingValue("ServiceProvider"); // string PayUSuccessUrl = context.GetWebConfigAppSettingValue("ClientPayUSuccessUrl"); // string PayUFailUrl = context.GetWebConfigAppSettingValue("ClientPayUFailUrl"); // string PayUBaseUrl = context.GetWebConfigAppSettingValue("PayUBaseUrl"); // var firstName = ObjSoldItems.PersonName; // var amount = ObjSoldItems.TotalAmount; // var productInfo = "School fees payment"; // var email = ObjSoldItems.Email; // var phone = ObjSoldItems.Mobile; // var key = MarchandKey; // var salt = Salt; // var myremotepost = new RemotePost { Url = PayUBaseUrl + "/_payment" }; // myremotepost.Add("key", key); // myremotepost.Add("txnid", ObjSoldItems.TxnUid); // myremotepost.Add("amount", amount.ToString()); // myremotepost.Add("productinfo", productInfo); // myremotepost.Add("firstname", firstName); // myremotepost.Add("phone", phone); // myremotepost.Add("email", email); // myremotepost.Add("surl", PayUSuccessUrl); // myremotepost.Add("furl", PayUFailUrl); // myremotepost.Add("service_provider", "payu_paisa"); // string hashString = key + "|" + ObjSoldItems.TxnUid + "|" + amount + "|" + productInfo + "|" + firstName + "|" + email + "|||||||||||" + salt; // string hash = accountService.Generatehash512(hashString); // myremotepost.Add("hash", hash); // myremotepost.Post(); // } // else // { // RedirectToAction("PayUReturnAction", "Home"); // } //} }