}//end upload post async Task LoadExcelAsync(string filePath) { List<TicketAllocationMongo> list = new List<TicketAllocationMongo>(); var dtContent = GetDataTableFromExcel(filePath); TicketAllocationMongo current; string identifier; int amount; foreach (DataRow dr in dtContent.Rows) { identifier = dr[0].ToString(); amount = int.Parse(dr[1].ToString()); current = new TicketAllocationMongo { LandingPageId = "fd8c412b-c1ef-4cb0-bcc8-b8b744b8b900", TicketAllocationId = "a2b210bf-d84a-40c1-b100-710978d3a56f ".Trim(), IdentifierId = identifier, BeginAmount = amount, CurrentAmount = amount }; //Debug.WriteLine(dr[0].ToString()); list.Add(current); } await mongoDbContext.TicketAllocationCollection.InsertManyAsync(list); Debug.WriteLine("total = " + list.Count); list.Clear(); }
public async Task <bool> UpdateAmountAsync(TicketAllocationMongo ticketAllocationMongo) { var toUpdate = Builders <TicketAllocationMongo> .Filter.Eq("_id", ticketAllocationMongo.Id); var result = await mongoDbContext.TicketAllocationCollection.UpdateOneAsync( toUpdate, Builders <TicketAllocationMongo> .Update .Set("CurrentAmount", ticketAllocationMongo.CurrentAmount)); if (result.ModifiedCount > 0) { return(true); } else { return(false); } } //end update amount