public async Task <int> SaveChangeAsync() { if (LstAdd.Count() > 0) { await db.AddRangeAsync(LstAdd); LstAdd = new List <TEntity>(); return(await db.SaveChangesAsync()); } if (LstDelete.Count() > 0) { db.RemoveRange(LstDelete); LstDelete = new List <TEntity>(); return(await db.SaveChangesAsync()); } if (LstUpdate.Count() > 0) { db.UpdateRange(LstUpdate); LstUpdate = new List <TEntity>(); return(await db.SaveChangesAsync()); } return(0); }
public async Task <bool> RemoveAsync(string Id, bool AutoSave) { if (AutoSave) { var entity = await GetById(Id); db.Set <TEntity>().Remove(entity); return(await db.SaveChangesAsync() > 0); } else { LstDelete.Add(await GetById(Id)); return(true); } }
private void InitialArray() { strHtmlDirectory = System.IO.Path.Combine(Server.MapPath("~"), "xml"); #region File TPxml path and name strFnTPxml = string.Format(InvariantCulture, "{0}{1}.xml", "TP", string.Format(InvariantCulture, "{0}_{1}", _action, _requestId)); #endregion File path and name #region File NDxml path and name strFnDeletexml = string.Format(InvariantCulture, "{0}{1}.xml", "ND", _requestId); #endregion File path and name DicDelNum = new Dictionary <string, int>(); for (int i = 1; i <= new CglDataSet(_gstuSearch.LottoType).LottoNumbers; i++) { DicDelNum.Add(string.Format(InvariantCulture, "{0}", i), 0); } DicDelHitCount = new Dictionary <string, int>(); DicAllNum = new Dictionary <string, string>(); UpdatelstDelete(_gstuSearch); LstDelete = LstDelete.Distinct().ToList(); LstNotDelete = LstNotDelete.Distinct().ToList(); }
private void GvHot_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int intNum = int.Parse(e.Row.Cells[0].Text, InvariantCulture); //號碼 int C0105 = int.Parse(e.Row.Cells[1].Text, InvariantCulture); //1-5 期 數據 int C0115 = int.Parse(e.Row.Cells[5].Text, InvariantCulture); //1-15 期 數據 int Miss = int.Parse(e.Row.Cells[4].Text, InvariantCulture); //遺漏數 string strCheck = string.Format(InvariantCulture, "{0}{1}{2:d2}", C0115, C0105, Miss); bool blDelete = LstDelete.Contains(strCheck); bool blNotDelete = LstNotDelete.Contains(strCheck); bool blHitNums = DicNumcssclass.ContainsKey(intNum.ToString(InvariantCulture)); UpdateAllNum(blDataTableCount, intNum, strCheck); switch (C0115) { case 0: #region C0115 == 2 if (blDelete) { if (UpdateDel(blNotDelete, blDataTableCount, strCheck)) { e.Row.CssClass = "row_lightseagreen"; } } #endregion C0115 == 2 break; case 1: #region C0115 == 2 if (blDelete) { if (UpdateDel(blNotDelete, blDataTableCount, strCheck)) { e.Row.CssClass = "row_lightseagreen"; } } #endregion C0115 == 2 break; case 2: #region C0115 == 2 if (blDelete) { if (UpdateDel(blNotDelete, blDataTableCount, strCheck)) { e.Row.CssClass = "row_lightseagreen"; } } #endregion C0115 == 2 break; case 3: #region C0115 == 3 if (blDelete) { if (UpdateDel(blNotDelete, blDataTableCount, strCheck)) { e.Row.CssClass = "row_lightskyblue"; } } #endregion C0115 == 3 break; case 4: #region C0115 == 4 if (blDelete) { if (UpdateDel(blNotDelete, blDataTableCount, strCheck)) { e.Row.CssClass = (C0105 > 0) ? "row_lightpink" : "row_lightgreen"; } } #endregion C0115 == 4 break; case 5: #region C0115 == 5 if (blDelete) { if (UpdateDel(blNotDelete, blDataTableCount, strCheck)) { e.Row.CssClass = (C0105 > 0) ? "row_lightblue" : "row_lightgreen"; } } #endregion C0115 == 5 break; default: #region C0115 >= 6 if (blDelete && C0115 >= 6) { if (UpdateDel(blNotDelete, blDataTableCount, strCheck)) { e.Row.CssClass = (C0105 > 0) ? "row_yellow" : "row_lightgreen"; } } #endregion C0115 >= 6 break; } if (blHitNums) { e.Row.Cells[0].CssClass = DicNumcssclass[intNum.ToString(InvariantCulture)]; } } }