static void Main(string[] args) { try { using (var db = new DataContext()) { var currentDate = DateTime.Today.AddYears(-1); while (currentDate <= DateTime.Today) { var rand = new Random(); var countPerDay = rand.Next(1, 20); for (int i = 0; i < countPerDay; i++) { var item = new GiaoDichLapSoTietKiem { KyHan = 6, LaiSuat = (float)5.0, MaKH = $"KH{i}", MaNV = $"NV{i}", SoTien = 100000, MaGD = AppUtils.GetTransactionID(LoaiGiaoDich.LapSoTietKiem, currentDate) + i.ToString(), TrangThai = TrangThaiGiaoDich.DangXuLy, NgayTao = currentDate }; db.GiaoDichLapSoTietKiems.Add(item); db.SaveChanges(); } currentDate = currentDate.AddDays(1); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } string baseAddress = $"http://localhost:{ConfigurationManager.AppSettings["port"] ?? "9001"}/"; using (WebApp.Start <Startup>(url: baseAddress)) { Console.WriteLine($"Transfer service was started at {baseAddress} \nPress any key to stop"); Console.ReadLine(); } }
public GiaoDichLapSoTietKiem HuyGiaoDich(GiaoDichLapSoTietKiem gd) { try { if (ModelState.IsValid && gd != null) { var giaoDich = db.GiaoDichLapSoTietKiems.Where(a => a.MaGD == gd.MaGD).FirstOrDefault(); if (giaoDich != null) { giaoDich.TrangThai = TrangThaiGiaoDich.Huy; db.SaveChanges(); return(gd); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(null); }
public GiaoDichLapSoTietKiem ThemGiaoDich(GiaoDichLapSoTietKiem gd) { try { if (ModelState.IsValid && gd != null) { gd.MaGD = AppUtils.GetTransactionID(LoaiGiaoDich.ChuyenTien, DateTime.Now); gd.TrangThai = TrangThaiGiaoDich.DangXuLy; gd.NgayTao = DateTime.Now; db.GiaoDichLapSoTietKiems.Add(gd); db.SaveChanges(); return(gd); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(null); }