public ActionResult DanhMucPartial() { using (ModelEntities context = new ModelEntities()) { return(PartialView(context.tbl_LoaiSanPhams.Where(p => p.DaXoa == false).ToList())); } }
//public static List<DTOArrivingChild> GetChildren(int groupId) //{ // using (ModelEntities db = new ModelEntities()) // { // return db.StudentInBus.Where(s => s.Student.groupId == groupId&&s.didCome==true).ToList().ConvertAll(s => ToDTO.DTOArrivingChild(s)); // } //} public static List <DTOPath> GetPath(int busId) { using (ModelEntities db = new ModelEntities()) { return(db.StudentInBus.Where(s => s.busId == busId).ToList().ConvertAll(s => ToDTO.DTOPath(s))); } }
private void FillPlayerNetWonTable() { if (!Schema.Table(handRecordsTableName).Exists()) { return; } using (var session = ModelEntities.OpenStatelessSession()) { using (var transaction = session.BeginTransaction()) { var currencyId = (int)Currency.USD; var sqlQuery = session .CreateSQLQuery($@"insert into {playerNetWonTableName} (PlayerId, Currency, NetWon) select h.PlayerId, {currencyId}, sum(h.NetWon) from {handRecordsTableName} h join GameInfo g on h.GameInfoId = g.GameInfoId where g.IsTournament = 0 and NetWon <> 0 group by PlayerId"); var result = sqlQuery.ExecuteUpdate(); LogProvider.Log.Info($"Inserted {result} rows into '{playerNetWonTableName}'"); transaction.Commit(); } } }
// GET: Admin/Cart public ActionResult Index() { List <Poco_DonHang_IndexPage> danhSachDonHang = new List <Poco_DonHang_IndexPage>(); using (ModelEntities ctx = new ModelEntities()) { List <tbl_PhieuOrders> list = ctx.tbl_PhieuOrders.Where(p => p.DaXoa == false).OrderByDescending(m => m.TinhTrangGiaoHang.Value).ToList(); List <tbl_NguoiSuDungs> listUser = ctx.tbl_NguoiSuDungs.ToList(); foreach (tbl_PhieuOrders item in list) { Poco_DonHang_IndexPage itemAdd = new Poco_DonHang_IndexPage(); itemAdd.ThongTinDonHang = new Poco_Info_DonHang(); itemAdd.ThongTinKhachHang = new Poco_Info_KhachHang(); itemAdd.ThongTinDonHang.MaDonHang = item.PhieuOrderID.ToString(); itemAdd.ThongTinDonHang.NgayLapPhieu = item.NgayLapPhieu.ToShortDateString(); itemAdd.ThongTinDonHang.GioLap = item.NgayLapPhieu.ToShortTimeString(); var User = listUser.Where(p => p.NguoiSuDungID == item.NguoiSuDungID).FirstOrDefault(); if (User == null) { itemAdd.ThongTinKhachHang.TenKhachHang = "Không xác định"; } else { itemAdd.ThongTinKhachHang.TenKhachHang = User.TenNguoiSuDung; } itemAdd.ThongTinDonHang.TongTien = item.TongTien; itemAdd.ThongTinDonHang.TinhTrangThanhToan = item.TinhTrangThanhToan.Value; itemAdd.ThongTinDonHang.TinhTrangGiaoHang = item.TinhTrangGiaoHang.Value; itemAdd.ThongTinDonHang.TongSoLuong = item.TongSoLuong.ToString(); danhSachDonHang.Add(itemAdd); } return(View(danhSachDonHang)); } }
public static bool isLogin() { if ((int)HttpContext.Current.Session["IsLogin"] == 1) { return(true); } else if (HttpContext.Current.Request.Cookies["Username"] != null) { //Không có session - > Kiểm tra cookies string userName = HttpContext.Current.Request.Cookies["Username"].Value; //Tìm trong CSDL using (ModelEntities ctx = new ModelEntities()) { tbl_NguoiSuDungs user = ctx.tbl_NguoiSuDungs.Where(p => String.Compare(p.TenDangNhap, userName) == 0).FirstOrDefault(); if (user != null) { //Tạo lại Sesstion HttpContext.Current.Session["IsLogin"] = 1; HttpContext.Current.Session["CurUser"] = user; return(true); } } } return(false); }
public List <tb_person> FindAllPatients() { using (database = new ModelEntities()) { return(database.tb_person.ToList()); } }
//GET: Home/Licencia public ActionResult Create() { List <Tabla> lst = null; using (ModelEntities db = new ModelEntities()) { lst = (from d in db.Empleados select new Tabla { Nombre = d.Nombre }).ToList(); }; List <SelectListItem> items = lst.ConvertAll(d => { return(new SelectListItem() { Text = d.Nombre.ToString(), Selected = false }); }); ViewBag.items = items; return(View()); }
// GET: Products/ByFactory public ActionResult ByFactory(int?id, int page = 1) { DangTruyVan = Loai.NhaSanXuat; if (!id.HasValue) { return(RedirectToAction("Index", "Home")); } using (ModelEntities ctx = new ModelEntities()) { ViewBag.CatID = id; int soPhanTu = 4; List <tbl_SanPhams> list = ctx.tbl_SanPhams.Where(p => p.NhaSanXuatID == id && p.DaXoa == false && p.TinhTrang == true).ToList(); Poco_Product_Page item = new Poco_Product_Page(); int soTrang = PhanTrang(list.Count, soPhanTu); item.DanhSachSanPham = list.Skip((page - 1) * soPhanTu).Take(soPhanTu).ToList(); item.SoPage = PhanTrang(list.Count, soPhanTu); item.CurPage = page; item.MaSanPham = id.Value; ViewBag.Pages = item.SoPage; ViewBag.CurPage = page; ViewBag.NextPage = page + 1; ViewBag.NextPage = page - 1; if (list.FirstOrDefault() != null) { int LSPID = list.First().LoaiSanPhamID.Value; item.TenLoaiSanPham = ctx.tbl_LoaiSanPhams.First(p => p.LoaiSanPhamID == LSPID).TenLoaiSanPham; } else { item.TenLoaiSanPham = string.Empty; } item.TenNhaSanXuat = ctx.tbl_NhaSanXuats.FirstOrDefault(p => p.NhaSanXuatID == id.Value).TenNhaSanXuat; return(View(item)); } }
public List <tb_exercise> FindAllExercise() { using (this.database = new ModelEntities()) { return(this.database.tb_exercise.ToList()); } }
public ActionResult NhaSanXuatPartial() { using (ModelEntities context = new ModelEntities()) { return(PartialView(context.tbl_NhaSanXuats.Where(p => p.DaXoa == false).ToList())); } }
public ActionResult Detail(int?id) { if (!id.HasValue) { return(RedirectToAction("Index", "Home")); } using (ModelEntities ctx = new ModelEntities()) { tbl_SanPhams n = ctx.tbl_SanPhams.Where(p => p.SanPhamID == id).FirstOrDefault(); Poco_Detail detail = new Poco_Detail(); detail.ThongTinSanPham = new tbl_SanPhams(); detail.ThongTinSanPham.SanPhamID = n.SanPhamID; detail.ThongTinSanPham.TenSanPham = n.TenSanPham; detail.ThongTinSanPham.DungTich = n.DungTich; detail.ThongTinSanPham.NongDo = n.NongDo; detail.ThongTinSanPham.Gia = n.Gia; detail.ThongTinSanPham.SoLanMua = n.SoLanMua; detail.ThongTinSanPham.SoLanXem = n.SoLanXem; detail.ThongTinSanPham.SoLuong = n.SoLuong; detail.ThongTinSanPham.TinhTrang = n.TinhTrang; detail.ThongTinSanPham.DaXoa = n.DaXoa; detail.ThongTinSanPham.MoTaDai = n.MoTaDai; detail.ThongTinSanPham.MoTaNgan = n.MoTaNgan; detail.ThongTinSanPham.NgayNhap = n.NgayNhap; detail.ThongTinSanPham.LoaiSanPhamID = n.LoaiSanPhamID; detail.ThongTinSanPham.NhaSanXuatID = n.NhaSanXuatID; detail.TenNhaSanXuat = ctx.tbl_NhaSanXuats.Where(p => p.NhaSanXuatID == n.NhaSanXuatID).First().TenNhaSanXuat; detail.TenLoaiSanPham = ctx.tbl_LoaiSanPhams.Where(p => p.LoaiSanPhamID == n.LoaiSanPhamID).First().TenLoaiSanPham; return(View(detail)); } }
public ActionResult Register(Poco_DangKy item) { if (!ModelState.IsValid) { return(View(3)); } tbl_NguoiSuDungs obj = new tbl_NguoiSuDungs(); obj.TenDangNhap = item.TenDangNhap; using (ModelEntities ctx = new ModelEntities()) { if (ctx.tbl_NguoiSuDungs.Any(p => p.TenDangNhap == item.TenDangNhap)) { return(View(2)); } } obj.MatKhau = StringUtils.Md5(item.MatKhau); obj.GioiTinh = item.GioiTinh; obj.NgaySinh = DateTime.ParseExact(item.NgaySinh, "dd/MM/yyyy", null); obj.DiaChi = item.DiaChi; obj.SoDienThoai = item.SoDienThoai; obj.TenNguoiSuDung = item.HoTen; obj.Quyen = 0; obj.DaXoa = false; using (ModelEntities ctx = new ModelEntities()) { ctx.tbl_NguoiSuDungs.Add(obj); ctx.SaveChanges(); } return(View(0)); }
public ActionResult Login(Poco_Login item) { using (ModelEntities ctx = new ModelEntities()) { tbl_NguoiSuDungs usr = ctx.tbl_NguoiSuDungs.Where(p => p.TenDangNhap == item.UserName).FirstOrDefault(); if (usr == null) { //Khong ton tai use ViewBag.Error = "zzz"; return(View(item)); } else { if (String.Compare(StringUtils.Md5(item.Password), usr.MatKhau) != 0) { ViewBag.Error = "zzz"; return(View(item)); } else { Session["IsLogin"] = 1; Session["CurUser"] = usr; if (item.Remeber) { HttpContext.Response.Cookies["Username"].Value = usr.TenDangNhap; HttpContext.Response.Cookies["Username"].Expires = DateTime.Now.AddDays(7); } return(RedirectToAction("Index", "Home")); } } } }
protected void CleanUpDatabase() { using (var perfScope = new PerformanceMonitor("CleanUpDatabase")) { using (var session = ModelEntities.OpenStatelessSession()) { using (var transaction = session.BeginTransaction()) { // order is important because of foreign keys var tablesToCleanUp = new string[] { "Tournaments", "HandNotes", "PlayerGameInfo", "HandsPlayers", "PlayerNotes", "HandHistories", "GameInfo", "Players", }; tablesToCleanUp.ForEach(x => session.CreateSQLQuery($"DELETE FROM \"{x}\"").ExecuteUpdate()); transaction.Commit(); } } } }
// GET: Admin/Products public ActionResult Index() { using (ModelEntities ctx = new ModelEntities()) { return(View(ctx.tbl_SanPhams.Where(p => p.DaXoa == false).ToList())); } }
public tb_exercise FindExerciseByID(int ID) { using (this.database = new ModelEntities()) { return(this.database.tb_exercise.SingleOrDefault(e => e.ExerciseID == ID)); } }
// GET: Salida/Edit/5 public ActionResult Edit(int id) { List <Tabla> lst = null; using (ModelEntities db = new ModelEntities()) { lst = (from d in db.Empleados select new Tabla { Nombre = d.Nombre }).ToList(); }; List <SelectListItem> items = lst.ConvertAll(d => { return(new SelectListItem() { Text = d.Nombre.ToString(), Selected = false }); }); ViewBag.items = items; var sal = CapaNegocio.GetSalida(id); return(View(sal)); }
public tb_person_exercise FindPersonExercise(string personID, int exerciseID) { using (this.database = new ModelEntities()) { return(this.database.tb_person_exercise.SingleOrDefault(e => e.ExerciseID == exerciseID && e.PersonID == personID)); } }
public tb_person FindPatientByCode(String code) { using (database = new ModelEntities()) { return(database.tb_person.SingleOrDefault(p => p.PersonID == code)); } }
public List <tb_exercise> FindExerciseByPerson(string personID) { using (this.database = new ModelEntities()) { return(this.database.tb_person_exercise.Where(e => e.PersonID == personID).Select(e => e.tb_exercise).ToList()); } }
public ViewModel(ModelEntities model, ICommand userRelate = null, ICommand itemRelated = null, ICommand itemRelated1 = null) { _model = model; UserRelate = userRelate; ItemRelated = itemRelated; ItemRelated1 = itemRelated1; }
public tb_config_practice FindConfigPracticeByID(int?configID) { using (this.database = new ModelEntities()) { return(this.database.tb_config_practice.SingleOrDefault(e => e.ConfigID == configID)); } }
public ActionResult SetGiaoHang(int?id, bool edit = false) { if (!id.HasValue) { if (edit == true) { return(RedirectToAction("Edit", new { id = id })); } return(RedirectToAction("Index")); } else { using (ModelEntities ctx = new ModelEntities()) { tbl_PhieuOrders itemFind = ctx.tbl_PhieuOrders.Where(p => p.PhieuOrderID == id.Value).FirstOrDefault(); itemFind.TinhTrangGiaoHang = true; ctx.SaveChanges(); if (edit == true) { return(RedirectToAction("Edit", new { id = id })); } return(RedirectToAction("Index")); } } }
// GET: Cart public ActionResult Index() { decimal total = 0; var cart = CurrentContext.Cart(); var list = new List <CartItemModel>(); using (ModelEntities ctx = new ModelEntities()) { foreach (CartItem ci in cart.Items) { var pro = ctx.tbl_SanPhams.Where(p => p.SanPhamID == ci.ProID).FirstOrDefault(); if (pro != null) { var cim = new CartItemModel { Item = ci, Product = pro }; total += (decimal)(pro.Gia * ci.Quantity); list.Add(cim); } } } ViewBag.Total = total; return(View(list)); }
public static List <DTOBus> GetaccompanierBus(int accompanierId) { using (ModelEntities db = new ModelEntities()) { return(db.Buses.Where(b => b.accompanierId == accompanierId).ToList().ConvertAll(b => ToDTO.DTOBus(b))); } }
public ActionResult Edit(tbl_SanPhams item, HttpPostedFileBase image) { using (ModelEntities ctx = new ModelEntities()) { tbl_SanPhams itemFind = ctx.tbl_SanPhams.Where(p => p.SanPhamID == item.SanPhamID).FirstOrDefault(); if (itemFind == null) { return(RedirectToAction("Index")); } itemFind.TenSanPham = item.TenSanPham; itemFind.Gia = item.Gia; itemFind.MoTaNgan = item.MoTaNgan; itemFind.MoTaDai = item.MoTaDai; itemFind.NongDo = item.NongDo; itemFind.SoLuong = item.SoLuong; itemFind.TinhTrang = item.TinhTrang; itemFind.LoaiSanPhamID = item.LoaiSanPhamID; itemFind.NhaSanXuatID = item.NhaSanXuatID; if (image != null && image.ContentLength > 0) { //Tao folder chua hinh string patch1 = Server.MapPath("~/image"); string tagetdir = Path.Combine(patch1, item.SanPhamID.ToString()); Directory.CreateDirectory(tagetdir); //Copy hinh string mainThumn = Path.Combine(tagetdir, "main_thumn.jpg"); image.SaveAs(mainThumn); } ctx.SaveChanges(); return(RedirectToAction("Edit", new { id = item.SanPhamID })); } }
public static List <DTOArrivingChild> CheckPresence(List <DTOArrivingChild> children) { using (ModelEntities db = new ModelEntities()) { return(children.Where(s => s.DidCome == false).ToList()); } }
public ActionResult Add(tbl_SanPhams model, HttpPostedFileBase image) { Poco_Page_ThemSanPham item = new Poco_Page_ThemSanPham(); if (string.IsNullOrEmpty(model.MoTaDai)) { model.MoTaDai = string.Empty; } if (string.IsNullOrEmpty(model.MoTaNgan)) { model.MoTaNgan = string.Empty; } model.DaXoa = false; model.SoLanXem = 0; model.SoLanMua = 0; model.NgayNhap = DateTime.Now; using (ModelEntities ctx = new ModelEntities()) { ctx.tbl_SanPhams.Add(model); ctx.SaveChanges(); item.DanhSachLoaiSanPham = ctx.tbl_LoaiSanPhams.ToList(); item.DanhSachNhaCungCap = ctx.tbl_NhaSanXuats.ToList(); if (image != null && image.ContentLength > 0) { //Tao folder chua hinh string patch1 = Server.MapPath("~/image"); string tagetdir = Path.Combine(patch1, model.SanPhamID.ToString()); Directory.CreateDirectory(tagetdir); //Copy hinh string mainThumn = Path.Combine(tagetdir, "main_thumn.jpg"); image.SaveAs(mainThumn); } return(View(item)); } }
private void FillPlayerGameInfoTable() { if (!Schema.Table(handRecordsTableName).Exists()) { return; } using (var session = ModelEntities.OpenStatelessSession()) { using (var transaction = session.BeginTransaction()) { var sqlQuery = session .CreateSQLQuery($@"insert into {playerGameInfoTableName} (PlayerId, GameInfoId) select PlayerId, GameInfoId from {handRecordsTableName} group by PlayerId, GameInfoId"); var result = sqlQuery.ExecuteUpdate(); LogProvider.Log.Info($"Inserted {result} rows into '{playerGameInfoTableName}'"); transaction.Commit(); } } }
public tb_patient FindPatientByCode(String code) { using (ModelEntities database = new ModelEntities()) { return(database.tb_patient.SingleOrDefault(p => p.PatientID == code)); } }