private void InsertVietLoot(VietlottVN obj) { try { if (obj != null && !_context.VietlottVNs.Any(o => o.DayPrize.Equals(obj.DayPrize))) { _context.VietlottVNs.InsertOnSubmit(obj); _context.SubmitChanges(); } } catch (Exception ex) { } }
public void ImportVietLottPage(List <VietlottVNDto> lst) { if (lst != null && lst.Count > 0) { foreach (var dto in lst) { try { var datePize = dto.DatePize.Trim(); DateTime dt = DateTime.ParseExact(datePize, "dd/MM/yyyy", CultureInfo.InvariantCulture); List <int> listNumberInt = new List <int>(); if (dto.ListNumbers != null && dto.ListNumbers.Count > 0) { foreach (var number in dto.ListNumbers) { int iNumber = 0; int.TryParse(number, out iNumber); if (iNumber > 0) { listNumberInt.Add(iNumber); } } } listNumberInt = listNumberInt.OrderBy(o => o).ToList(); if (dto.ListNumbers != null && listNumberInt.Count == 6) { var obj = new VietlottVN() { DayPrize = dt, DrawId = 0, FullBlockNumber = String.Join(" ", dto.ListNumbers), ImportDate = DateTime.UtcNow, NumberOne = listNumberInt[0], NumberTwo = listNumberInt[1], NumberThree = listNumberInt[2], NumberFour = listNumberInt[3], NumberFive = listNumberInt[4], NumberSix = listNumberInt[5] }; InsertVietLoot(obj); } } catch (Exception exception) { ; } } } }
/// <summary> /// Import VietLott /// </summary> /// <param name="obj"></param> public void ImportVietlottVN(VietlottVNDto obj) { var vObj = _dataContext.VietlottVNs.FirstOrDefault(o => o.DrawId == obj.DrawId && o.DayPrize == obj.DatePizeDateTime); if (vObj == null) { var dbEntity = new VietlottVN() { DrawId = obj.DrawId, DayPrize = obj.DatePizeDateTime, FullBlockNumber = obj.FullBlockNumber, ImportDate = DateTime.Now, NumberOne = obj.NumberOne, NumberTwo = obj.NumberTwo, NumberThree = obj.NumberThree, NumberFour = obj.NumberFour, NumberFive = obj.NumberFive, NumberSix = obj.NumberSix }; _dataContext.VietlottVNs.InsertOnSubmit(dbEntity); _dataContext.SubmitChanges(); } }
partial void DeleteVietlottVN(VietlottVN instance);
partial void UpdateVietlottVN(VietlottVN instance);
partial void InsertVietlottVN(VietlottVN instance);