//public int GetShopId() //{ // if (IsAdminLogin()) // { // var admin = GetAdminInfo(); // BLL.wx_diancai_admin shopAdminBll = new BLL.wx_diancai_admin(); // Model.wx_diancai_admin shopAdmin = shopAdminBll.GetModel(admin.id); // if (shopAdmin != null) // { // return shopAdmin.ShopId; // } // BLL.wx_diancai_shop_user suBll = new BLL.wx_diancai_shop_user(); // Model.wx_diancai_shop_user shopUser = suBll.GetModel(admin.id); // if (shopUser != null) // { // return shopUser.ShopId; // } // return 0; // } // return 0; //} public int GetHotelId() { if (IsAdminLogin()) { var admin = GetAdminInfo(); using (var dbContext = new HotelDbContext()) { var adminService = new HotelAdminService(new HotelAdminRepository(dbContext)); var hotelAdmin = adminService.GetModel(admin.id); if (hotelAdmin != null) { return(hotelAdmin.HotelId); } var userService = new HotelUserService(new HotelUserRepository(dbContext)); var hotelUser = userService.GetModel(admin.id); if (hotelUser != null) { return(hotelUser.HotelId); } } return(0); } return(0); }
public void HotelAddUser_HotelUser_ReturnNewUserId() { var service=new HotelUserService(new HotelUserRepository(new HotelDbContext())); var result = service.Add(new HotelUserInfo() {AdminId = 1,HotelId = 1,ManagerId = 1}); Assert.IsTrue(result.Equals(0)); }
public void HotelAddUser_HotelUser_ReturnNewUserId() { var service = new HotelUserService(new HotelUserRepository(new HotelDbContext())); var result = service.Add(new HotelUserInfo() { AdminId = 1, HotelId = 1, ManagerId = 1 }); Assert.IsTrue(result.Equals(0)); }
//新增用户 public static bool AddHotelUser(HotelUser hotelUser) { //判断用户是否存在 HotelUser user = HotelUserService.GetHotelUserByUserName(hotelUser.UserName); if (user == null) { HotelUserService.AddHotelUser(hotelUser); return(true); } else { return(false); } }
private bool IsHotelAdmin(int id) { using (var context = new HotelDbContext()) { var hotelAdminService = new HotelAdminService(new HotelAdminRepository(context)); var hotelAdminInfo = hotelAdminService.GetModel(id); if (hotelAdminInfo != null) { return(true); } var hotelUserService = new HotelUserService(new HotelUserRepository(context)); var hotelUserInfo = hotelUserService.GetModel(id); if (hotelUserInfo != null) { return(true); } } return(false); }
//private bool IsShopAdmin(int id) //{ // BLL.wx_diancai_admin dBll = new BLL.wx_diancai_admin(); // Model.wx_diancai_admin shopAdmin = dBll.GetModel(id); // //餐饮 商铺管理员 // if (shopAdmin != null) // { // //Session[MXKeys.WEIXIN_DIANCAI_SHOPID] = shopAdmin.ShopId; // //Utils.WriteCookie(MXKeys.WEIXIN_DIANCAI_SHOPID, "WeiXinPF", shopAdmin.ShopId.ToString()); // return true; // } // BLL.wx_diancai_shop_user suBll = new BLL.wx_diancai_shop_user(); // Model.wx_diancai_shop_user shopUser = suBll.GetModel(id); // if (shopUser != null) // { // //Session[MXKeys.WEIXIN_DIANCAI_SHOPID] = shopUser.ShopId; // //Utils.WriteCookie(MXKeys.WEIXIN_DIANCAI_SHOPID, "WeiXinPF", shopUser.ShopId.ToString()); // return true; // } // return false; //} private bool IsHotelAdmin(int id) { using (var context = new HotelDbContext()) //todo: CodeReview的时候注意context放在这是否合适? { var hotelAdminService = new HotelAdminService(new HotelAdminRepository(context)); var adminInfo = hotelAdminService.GetModel(id); //酒店管理员 if (adminInfo != null) { return(true); } var hotelUserService = new HotelUserService(new HotelUserRepository(context)); var hotelUserInfo = hotelUserService.GetModel(id); if (hotelUserInfo != null) { return(true); } return(false); } }
//public int GetShopId() //{ // if (IsAdminLogin()) // { // var admin = GetAdminInfo(); // BLL.wx_diancai_admin shopAdminBll = new BLL.wx_diancai_admin(); // Model.wx_diancai_admin shopAdmin = shopAdminBll.GetModel(admin.id); // if (shopAdmin != null) // { // return shopAdmin.ShopId; // } // BLL.wx_diancai_shop_user suBll = new BLL.wx_diancai_shop_user(); // Model.wx_diancai_shop_user shopUser = suBll.GetModel(admin.id); // if (shopUser != null) // { // return shopUser.ShopId; // } // return 0; // } // return 0; //} public int GetHotelId() { if (IsAdminLogin()) { var admin = GetAdminInfo(); using (var dbContext = new HotelDbContext()) { var adminService = new HotelAdminService(new HotelAdminRepository(dbContext)); var hotelAdmin = adminService.GetModel(admin.id); if (hotelAdmin != null) { return hotelAdmin.HotelId; } var userService = new HotelUserService(new HotelUserRepository(dbContext)); var hotelUser = userService.GetModel(admin.id); if (hotelUser != null) { return hotelUser.HotelId; } } return 0; } return 0; }
//根据用户名得到用户 public static HotelUser GetHotelUser(string userName) { return(HotelUserService.GetHotelUserByUserName(userName)); }
//根据用户ID得到用户 public static HotelUser GetHotelUserByUserID(int userID) { return(HotelUserService.GetHotelUserByUserID(userID)); }
//得到用户列表 public static IList <HotelUser> GetAllHotelUsers() { return(HotelUserService.GetAllHotelUsers()); }
//修改用户 public static void ModifyHotelUser(HotelUser hotelUser) { HotelUserService.ModifyHotelUser(hotelUser); }
//根据用户ID删除用户 public static void DeleteHotelUserById(int userID) { HotelUserService.DeleteHotelUserByUserID(userID); }
//删除用户 public static void DeleteHotelUser(HotelUser hotelUser) { HotelUserService.DeleteHotelUser(hotelUser); }