public ActionResult Index() { ViewBag.__auth = MySsAuthUsers.GetAuth(); Quan vm = new Quan(); return(View(vm)); }
public ActionResult Print() { var __auth = MySsAuthUsers.GetAuth(); var model = __db.Ban.Where(w => w.Quan.UserId == __auth.ID); return(View(model)); }
public ActionResult ChonQuanMacDinh(int?id) { var __auth = MySsAuthUsers.GetAuth(); var user = __db.Users.Find(__auth.ID); if (id.HasValue) { try { user.QuanDefaultId = id; __db.SaveChanges(); } catch (Exception ex) { } } var dsQuanSoHuu = new List <Quan>(); if (user.OwnerId != null) { dsQuanSoHuu = __db.UserQuan.Where(w => w.UserID == __auth.ID).Select(s => s.Quan).ToList(); } else { dsQuanSoHuu = __db.Quan.Where(w => w.UserId == __auth.ID).ToList(); } ViewBag.id = user.QuanDefaultId; return(View(dsQuanSoHuu)); }
public ActionResult Index() { var __auth = MySsAuthUsers.GetAuth(); IEnumerable <SelectListItem> ddlQuan = new List <SelectListItem>(); var user = __db.Users.Find(__auth.ID); if (__auth.IsOwner) { ddlQuan = __db.Quan.Where(w => w.UserId == __auth.ID).Select(s => new SelectListItem() { Text = s.TenQuan, Value = s.Id.ToString(), Selected = s.Id == user.QuanDefaultId }); } else { ddlQuan = __db.UserQuan.Where(w => w.UserID == __auth.ID).Select(s => s.Quan).Select(s => new SelectListItem() { Text = s.TenQuan, Value = s.Id.ToString(), Selected = s.Id == user.QuanDefaultId }); } var vm = new DonHang(); ViewBag.ddlQuan = ddlQuan; ViewBag.QuanDefaultId = user.QuanDefaultId; ViewBag.BaseUserId = __auth.ID; return(View(vm)); }
// GET: Admin/Quans/Edit/5 public ActionResult Edit(int id) { var auth = MySsAuthUsers.GetAuth(); Quan entity = _QuanServ.GetEntry(id); QuanCRUD vm = new QuanCRUD(); vm.Id = entity.Id; vm.MaQuan = entity.MaQuan; vm.TenQuan = entity.TenQuan; if (string.IsNullOrWhiteSpace(vm.ImageThumbnail)) { vm.ImageThumbnail = "/Content/images/sample/shop2.png"; //model.Image; } else { vm.ImageThumbnail = entity.ImageThumbnail; } vm.DiaChi = entity.DiaChi; vm.DienThoai = entity.DienThoai; if (auth.RoleId == 1) { vm.DanhSachNhanVien = new List <User>(); } else { vm.DanhSachNhanVien = __db.Users.Where(w => w.OwnerId == auth.ID); } ViewBag.__auth = auth; vm.DanhSachNhanVienChon = entity.UserQuans.Select(s => s.UserID).ToList(); vm.BanArr = entity.BanArr; vm.ChuQuan = new FrmCreateUserVM(); return(View(vm)); }
public JsonResult ajax_lay_quan_mac_dinh() { var __auth = MySsAuthUsers.GetAuth(); int QuanDefaultId = __db.Users.Find(__auth.ID).QuanDefaultId ?? -1; return(Json(QuanDefaultId, JsonRequestBehavior.AllowGet)); }
// GET: Admin/Users/Edit/5 public ActionResult EditUser(int id) { var __auth = MySsAuthUsers.GetAuth(); ViewBag.__auth = __auth; User user = _userServ.GetEntry(id); if (user == null) { return(HttpNotFound()); } ViewBag.ddlRole = _roleServ.GetList(w => w.Id == 2).ToList().Select(s => new SelectListItem() { Text = s.Name, Value = s.Id.ToString() }); ViewBag.dsQuyen = _permisionServ.GetList().ToList(); SimpleAES aes = new SimpleAES(); user.Password = aes.DecryptString(user.Password); FrmCreateUserVM model = Mapper.Map <User, FrmCreateUserVM>(user); model.ddlGioiTinh = new List <SelectListItem>() { new SelectListItem() { Text = "Nam", Value = "Nam" }, new SelectListItem() { Text = "Nữ", Value = "Nữ" } }; return(View(model)); }
public ActionResult Delete(int id) { var __auth = MySsAuthUsers.GetAuth(); rs r; try { User user = _userServ.GetEntry(id); if (user.Username.ToLower() == "admin" || user.Id == __auth.ID) { r = rs.F("Không thể xóa admin/owner"); } else { _userServ.Delete(user); _userServ.Save(); } r = rs.T("Ok"); } catch (Exception ex) { r = rs.F("Lỗi: " + ex.Message); } return(Json(r, JsonRequestBehavior.DenyGet)); }
public JsonResult CapNhatProccess(CapNhatUserVM model) { rs r; SimpleAES __aes = new SimpleAES(); if (ModelState.IsValid) { var __id = MySsAuthUsers.GetAuth().ID; using (var __db = new vuong_cms_context()) { var user = __db.Users.Find(__id); user.Phone = model.Phone; user.Address = model.Address; user.Fullname = model.Fullname; __db.SaveChanges(); r = rs.T("Ok"); } } else { r = rs.F("Vui lòng điền đầy đủ thông tin!"); } return(Json(r, JsonRequestBehavior.DenyGet)); }
public PartialViewResult ajax_paging(donhang_sp paging) { var __auth = MySsAuthUsers.GetAuth(); PG <DonHang> vmpg; if (__auth.RoleId == 1) { vmpg = _DonHangServ.GetQueryPaging(paging); } else { vmpg = _DonHangServ.GetQueryPaging(paging, w => w.BaseUserId == __auth.OwnerId); } ViewBag.ddlTrangThaiGiaoHang = __db.TrangThaiGiaoHang.Select(s => new SelectListItem() { Text = s.Ten, Value = s.Id.ToString() }); ViewBag.ddlTrangThaiThanhToan = __db.TrangThaiThanhToan.Select(s => new SelectListItem() { Text = s.Ten, Value = s.Id.ToString() }); return(PartialView(vmpg)); }
public JsonResult DoiMatKhauProccess(DoiMatKhauVM model) { rs r; SimpleAES __aes = new SimpleAES(); if (ModelState.IsValid) { var __oldpw = __aes.EncryptToString(model.MatKhauHienTai); var __newpw = __aes.EncryptToString(model.MatKhauMoi); var __id = MySsAuthUsers.GetAuth().ID; using (var __db = new vuong_cms_context()) { var user = __db.Users.Find(__id); if (user.Password == __oldpw) { user.Password = __newpw; __db.SaveChanges(); r = rs.T("Ok"); } else { r = rs.F("Mật khẩu hiện tại không chính xác!"); } } } else { r = rs.F("Vui lòng điền đầy đủ thông tin!"); } return(Json(r, JsonRequestBehavior.DenyGet)); }
// GET: Admin/Users/Create public ActionResult Create() { var __auth = MySsAuthUsers.GetAuth(); ViewBag.ddlRole = _roleServ.GetList(w => w.Id == 3).ToList().Select(s => new SelectListItem() { Text = s.Name, Value = s.Id.ToString() }); ViewBag.dsQuyen = _permisionServ.GetList().ToList(); var model = new FrmCreateUserVM(); model.ddlGioiTinh = new List <SelectListItem>() { new SelectListItem() { Text = "Nam", Value = "Nam" }, new SelectListItem() { Text = "Nữ", Value = "Nữ" } }; model.DanhSachQuan = __db.Quan.Where(w => w.UserId == __auth.ID); model.DanhSachQuanChon = __db.UserQuan.Where(w => w.UserID == __auth.ID).Select(s => s.QuanID).ToList(); return(View(model)); }
public ActionResult LichSuNapThe() { int _id = MySsAuthUsers.GetAuth().ID; vuong_cms_context __db = new vuong_cms_context(); var model = __db.LichSuNapThe.Where(w => w.UserId == _id).OrderByDescending(o => o.ngay); return(View(model)); }
public ActionResult CTDonHang(int Id) { int _id = MySsAuthUsers.GetAuth().ID; vuong_cms_context __db = new vuong_cms_context(); var model = __db.DonHangs.FirstOrDefault(w => w.Id == Id); return(View(model)); }
public ActionResult DonHang() { int _id = MySsAuthUsers.GetAuth().ID; vuong_cms_context __db = new vuong_cms_context(); var model = __db.DonHangs.Where(w => w.UserId == _id).OrderByDescending(o => o.CreatedDate); return(View(model)); }
public ActionResult Profile() { var au = MySsAuthUsers.GetAuth(); vuong_cms_context __db = new vuong_cms_context(); var model = __db.Users.Find(au.ID); return(View(model)); }
public PartialViewResult ajax_paging(smartpaging paging) { var __auth = MySsAuthUsers.GetAuth(); PG <Ban> vmpg; vmpg = _BanServ.GetQueryPaging(paging, w => w.Quan.UserId == __auth.OwnerId); return(PartialView(vmpg)); }
public PartialViewResult LeftNav() { var __auth = MySsAuthUsers.GetAuth(); User _user = __db.Users.Find(__auth.ID); return(PartialView(_user)); }
public PartialViewResult ajax_paging(User_filter paging) { var __auth = MySsAuthUsers.GetAuth(); PG <User> vmpg; vmpg = _userServ.GetQueryPaging(paging, w => w.OwnerId == __auth.ID); return(PartialView(vmpg)); }
public void RefreshLogin() { var ss = MySsAuthUsers.GetAuth(); if (ss != null) { var log = base.FirstOrDefault(f => f.Id == ss.ID); var newss = new loginVM(log); MySsAuthUsers.setLogin(newss); } }
// GET: Admin/Bans/Create public ActionResult Create(int catid = -1) { var __auth = MySsAuthUsers.GetAuth(); BanCRUD vm = new BanCRUD(); vm.ddlQuan = __db.Quan.Where(w => w.UserId == __auth.ID).ToList().Select(s => new SelectListItem() { Text = s.TenQuan, Value = s.Id.ToString(), }); return(View(vm)); }
//lấy quán public JsonResult ajax_get_quan() { var __auth = MySsAuthUsers.GetAuth(); var rs = __db.Quan.Where(w => w.UserId == __auth.ID).ToList().Select(s => new Quan { TenQuan = s.TenQuan, Id = s.Id, ImageThumbnail = s.ImageThumbnail, }).ToList(); return(Json(rs, JsonRequestBehavior.AllowGet)); }
public ActionResult Create() { var __auth = MySsAuthUsers.GetAuth(); ProductCatCRUD vm = new ProductCatCRUD(); vm.ddlQuan = __db.Quan.Where(w => w.UserId == __auth.ID).ToList().Select(s => new SelectListItem() { Text = "[" + s.MaQuan + "] " + s.TenQuan, Value = s.Id.ToString() }); //vm.ParentId = -1; return(View(vm)); }
public JsonResult ajax_get_dssp(int QuanId) { var __auth = MySsAuthUsers.GetAuth(); var rs = __db.Product.Where(w => w.ProductCat.Quan.UserId == __auth.ID).ToList().Select(s => new Product() { Id = s.Id, ProductName = s.ProductName, ThumbnailImage = s.ThumbnailImage, Price = s.Price, }); return(Json(rs, JsonRequestBehavior.AllowGet)); }
public JsonResult ajax_auth_ddlquan() { var __auth = MySsAuthUsers.GetAuth(); List <Quan> ddlQuan; var user = __db.Users.Find(__auth.ID); if (__auth.RoleId == 1) { ddlQuan = __db.Quan.ToList().Select(s => new Quan() { Id = s.Id, TenQuan = s.TenQuan, ProductCats = s.ProductCats.ToList().Select(s2 => new ProductCat() { Id = s2.Id, Name = s2.Name, }).ToList(), BanArr = s.BanArr }).ToList(); } else if (__auth.IsOwner) { ddlQuan = __db.Quan.Where(w => w.UserId == __auth.ID).ToList().Select(s => new Quan() { Id = s.Id, TenQuan = s.TenQuan, ProductCats = s.ProductCats.ToList().Select(s2 => new ProductCat() { Id = s2.Id, Name = s2.Name, }).ToList(), BanArr = s.BanArr }).ToList(); } else { ddlQuan = __db.UserQuan.Where(w => w.UserID == __auth.ID).Select(s => s.Quan).ToList().Select(s => new Quan() { Id = s.Id, TenQuan = s.TenQuan, ProductCats = s.ProductCats.ToList().Select(s2 => new ProductCat() { Id = s2.Id, Name = s2.Name, }).ToList(), BanArr = s.BanArr }).ToList(); } return(Json(ddlQuan, JsonRequestBehavior.AllowGet)); }
//lấy ds thực đơn public JsonResult ajax_get_thucdon(int quan_id) { var __auth = MySsAuthUsers.GetAuth(); List <ThucDonVM> vm = new List <ThucDonVM>(); var rs = __db.ThucDon.Where(w => w.Quan.UserId == __auth.ID && w.QuanId == quan_id).Select(s => new ThucDonVM() { Id = s.Id, TenThucDon = s.TenThucDon, Icon = s.Icon, QuanId = s.QuanId, }); return(Json(rs, JsonRequestBehavior.AllowGet)); }
public ActionResult CapNhat() { var __id = MySsAuthUsers.GetAuth().ID; CapNhatUserVM model = new CapNhatUserVM(); using (var __db = new vuong_cms_context()) { var user = __db.Users.Find(__id); model.Username = user.Username; model.Phone = user.Phone; model.Address = user.Address; model.Fullname = user.Fullname; } return(View(model)); }
public PartialViewResult ajax_paging(smartpaging paging) { var __auth = MySsAuthUsers.GetAuth(); PG <Product> vmpg; if (__auth.Username == "admin") { vmpg = _ProductServ.GetQueryPaging(paging); } else { vmpg = _ProductServ.GetQueryPaging(paging, w => w.ProductCat.Quan.UserId == __auth.OwnerId); } return(PartialView(vmpg)); }
public JsonResult CheckUserLogin() { var au = MySsAuthUsers.GetAuth(); rs r; if (au != null && au.RoleId == 2) { r = rs.T("Ok"); } else { r = rs.F("Vui lòng đăng nhập tài khoản người dùng!"); } return(Json(r, JsonRequestBehavior.AllowGet)); }
public JsonResult Create(FrmCreateUserVM model) { var __auth = MySsAuthUsers.GetAuth(); rs r; if (_userServ.Count(s => s.Username == model.Username) == 0) { try { SimpleAES __aes = new SimpleAES(); User entity = new User(); //pass encode entity.Username = model.Username; entity.Password = __aes.EncryptToString(model.Password); entity.RoleId = model.RoleId; entity.UserStatusId = 1; entity.Address = model.Address; entity.Phone = model.Phone; entity.GioiTinh = model.GioiTinh; entity.Fullname = model.Username; entity.OwnerId = __auth.ID; entity.Image = model.Image; entity.UserQuans = new Collection <UserQuan>(); //danh sach nhan vien quan ly foreach (var item in model.QuanIntIDs) { entity.UserQuans.Add(new UserQuan() { QuanID = item, UserID = entity.Id }); } __db.Users.Add(entity); __db.SaveChanges(); r = rs.T("Okay"); } catch (Exception ex) { r = rs.F("Lỗi: " + ex.Message); } } else { r = rs.F("Lỗi:tên đăng nhập đã tồn tại vui lòng chọn tên khác"); } return(Json(r, JsonRequestBehavior.DenyGet)); }