Example #1
0
        //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;
        }
Example #2
0
        //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;
            }
        }
Example #3
0
        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;
        }