public string LockLichSuGianHang(string id) { LichSuGianHang lichsugianhang = context.LichSuGianHang.Where(gh => gh.Id == Guid.Parse(id)).SingleOrDefault(); lichsugianhang.TinhTrang = "Khoá"; context.SaveChanges(); return("Khoá thành công"); }
public string EditLichSuGianHang(string id, string idgianhang) { LichSuGianHang lichsugianhang = context.LichSuGianHang.Where(gh => gh.Id == Guid.Parse(id)).SingleOrDefault(); GianHang gianhang = context.GianHang.Where(gh => gh.Id == Guid.Parse(idgianhang)).SingleOrDefault(); lichsugianhang.IdGianHang = Guid.Parse(idgianhang); lichsugianhang.NgayKetThuc = lichsugianhang.NgayBatDau.Value.AddDays((double)gianhang.ThoiGian); context.SaveChanges(); return("Sửa thành công"); }
public string CreateLichSuGianHang(string tendangnhap, string gianhang) { LichSuGianHang lichsugianhang = new LichSuGianHang(); TaiKhoan taikhoan = context.TaiKhoan.Where(tk => tk.TenDangNhap == tendangnhap).SingleOrDefault(); lichsugianhang.Id = Guid.Parse(Guid.NewGuid().ToString().ToUpper()); lichsugianhang.IdTaiKhoan = taikhoan.Id; lichsugianhang.IdGianHang = Guid.Parse(gianhang); lichsugianhang.NgayDangKy = DateTime.Now; lichsugianhang.TinhTrang = "Không khoá"; context.LichSuGianHang.Add(lichsugianhang); context.SaveChanges(); return("Thêm thành công"); }