Exemplo n.º 1
0
        public static IdentifyingCodeInfo GetConfirmIdentifyingCodeInfo(int shopId, string identifyingCode, string moduleName, int wid)
        {

            if (shopId == 0 || string.IsNullOrEmpty(identifyingCode) || string.IsNullOrEmpty(moduleName))
            {
                return null;
            }

            try
            {
                using (var context = new HotelDbContext())
                {
                    IIdentifyingCodeRepository repository = new IdentifyingCodeRepository(context); //改造方向:依赖注入,彻底去除对Infrastructure层的依赖

                    var strShop = shopId.ToString(CultureInfo.InvariantCulture);
                    return
                        repository.Get(
                            item =>
                            item.ShopId == strShop
                            && item.IdentifyingCode.Equals(identifyingCode)
                            && item.ModuleName.Equals(moduleName)
                            && item.Wid.Equals(wid)).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {

                throw;
            }

        }
Exemplo n.º 2
0
        public static IdentifyingCodeInfo GetIdentifyingCodeInfoByIdentifyingCodeId(Guid identifyingCodeId, string moduleName, int wid)
        {
            if (identifyingCodeId == null || Guid.Empty.Equals(identifyingCodeId))
            {
                return null;
            }

            try
            {
                using (var context = new HotelDbContext())
                {
                    IIdentifyingCodeRepository repository = new IdentifyingCodeRepository(context); //改造方向:依赖注入,彻底去除对Infrastructure层的依赖

                    return
                        repository.Get(
                                item => item.IdentifyingCodeId.Equals(identifyingCodeId)
                                        && item.ModuleName.Equals(moduleName)
                                        && item.Wid.Equals(wid)).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {

                throw;
            }

        }
Exemplo n.º 3
0
        public static bool MakeUseOfIdentifyingCode(Guid identifyingCodeId)
        {
            if (identifyingCodeId == null || Guid.Empty.Equals(identifyingCodeId))
            {
                return false;
            }

            using (var context = new HotelDbContext())
            {
                IIdentifyingCodeRepository repository = new IdentifyingCodeRepository(context); //改造方向:依赖注入,彻底去除对Infrastructure层的依赖

                repository.MakeUseOfIdentifyingCode(identifyingCodeId);
            }

            return true;
        }
Exemplo n.º 4
0
 public RoomRepository(HotelDbContext context)
 {
     _context = context;
 }
Exemplo n.º 5
0
        public static bool AddIdentifyingCode(IdentifyingCodeInfo code)
        {
            if (code != null)
            {
                var addResult = false;
                code.IdentifyingCode = Utils.Number(12);

                using (var context = new HotelDbContext())
                {
                    addResult = new IdentifyingCodeRepository(context).AddIdentifyingCode(code);
                }

                // 如果IdentifyingCode在数据库中存在,则递归执行此方法重新获取编号
                if (!addResult)
                {
                    AddIdentifyingCode(code);
                }
                else
                {
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 6
0
 public IndexModel(HotelDbContext context)
 {
     this.context = context;
 }
 public HotelRoomDatabaseRepository(HotelDbContext context)
 {
     _context = context;
 }
 public ClientsController(HotelDbContext context)
 {
     _context = context;
 }
Exemplo n.º 9
0
 public RoomTypeRepo(HotelDbContext context, IMapper mapper)
 {
     Context = context;
     Mapper  = mapper;
 }
Exemplo n.º 10
0
        public static IQueryable <HotelRoom> FilterByDateAvailability(this IQueryable <HotelRoom> list,
                                                                      DateTime?moveInDate, DateTime?moveOutDate, int maxElapsedMinutes, HotelDbContext dataContext)
        {
            if (moveInDate == null || moveOutDate == null || list == null)
            {
                return(list);
            }

            var filteredList = from hr in list
                               join r in dataContext.RoomReservations on hr.HotelRoomId equals r.HotelRoomId into res
                               from r in res.DefaultIfEmpty()
                               join s in dataContext.ReservationStatuses on r.StatusId equals s.ReservationStatusId into srv
                               from status in srv.DefaultIfEmpty()
                               //Here left join is used, that's why RoomReservationId and ReservationStatusId can be null.
                               //This check is necessary for including available rooms but without existing reservations.
                               where (r.RoomReservationId == null) ||
                               (r.MoveInDate > moveOutDate || r.MoveOutDate < moveInDate) ||
                               (status.ReservationStatusId == null) ||
                               (status.ReservationStatusId == (int)ReservationStatusEnum.Cancelled) ||
                               ((status.ReservationStatusId == (int)ReservationStatusEnum.Pending) &&
                                r.Created.AddSeconds(maxElapsedMinutes) > DateTimeOffset.UtcNow
                               )
                               select hr;

            return(filteredList);
        }
Exemplo n.º 11
0
 public BookingsRepository(HotelDbContext context)
 {
     database = context;
 }
Exemplo n.º 12
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;
        }
Exemplo n.º 13
0
 public BookingServices(HotelDbContext context, IBookingRepository bookingRepository) : base(context)
 {
     BookingRepository = bookingRepository;
 }
Exemplo n.º 14
0
        /// <summary>
        /// 取得当前微信帐号信息
        /// </summary>
        public WX_UserWeixinInfo GetWeiXinCode()
        {
            if (IsWeiXinCode())
            {
                var model = Session["nowweixin"] as WX_UserWeixinInfo;
                if (model != null)
                {
                    return model;
                }
            }
            else
            {
                //int shopid = GetShopId();
                //if (shopid != 0)
                //{
                //    BLL.wx_diancai_shopinfo shopBll = new BLL.wx_diancai_shopinfo();
                //    Model.wx_diancai_shopinfo shop = shopBll.GetModel(shopid);

                //    return new BLL.wx_userweixin().GetModel(shop.wid.Value);
                //}

                int hotelid = GetHotelId();
                if (hotelid != 0)
                {
                    HotelInfo hotel = null;

                    using (var dbContext = new HotelDbContext())
                    {                        
                        hotel = new HotelService(new HotelRepository()).GetModel(hotelid);                        
                    }

                    if (hotel !=null)
                    {
                        return new WXUserService(new WXUserRepository()).GetModel(hotel.wid.Value);
                    }
                    
                }
                Response.Write("<script>parent.location.href='http://" + HttpContext.Current.Request.Url.Authority + "/admin/weixin/myweixinlist.aspx'</script>");
                Response.End();
            }
            return null;
        }
 public RoomsController(HotelDbContext context)
 {
     _context = context;
 }
Exemplo n.º 16
0
 public CustomerServices(HotelDbContext context, ICustomerRepository customerRepository) : base(context)
 {
     CustomerRepository = customerRepository;
 }
Exemplo n.º 17
0
 public NewGuestVM()
 {
     AddGuest = new RelayCommand <object>(dodaj, parametar => true);
     using (var db = new HotelDbContext()) Id = db.Gosti.Last().Id++.ToString();
 }
Exemplo n.º 18
0
 public GetUserQueryHandlerTests(QueryTestFixture fixture)
 {
     context = fixture.Context;
     mapper  = fixture.Mapper;
 }
 public TrainStationServices(HotelDbContext context, ITrainStationRepository trainStationRepository) : base(context)
 {
     TrainStationRepository = trainStationRepository;
 }
Exemplo n.º 20
0
 public UnitOfWork(HotelDbContext context)
 {
     Context = context;
 }
Exemplo n.º 21
0
        public static IQueryable <HotelRoom> FilterRooms(this IQueryable <HotelRoom> rooms,
                                                         FilteredRoomsRequestModel filters, int maxElapsedMinutes, HotelDbContext dataContext = null)
        {
            if (filters == null)
            {
                return(rooms);
            }

            if (filters.RoomId != null)
            {
                return(rooms.FilterById(filters.RoomId));
            }

            if (filters.Number != null)
            {
                return(rooms.FilterByNumber(filters.Number));
            }

            return(rooms
                   .FilterByAdultAmount(filters.Adults)
                   //.FilterByCost(filters.MinCost, filters.MaxCost)
                   .FilterByDateAvailability(filters.MoveInDate, filters.MoveOutDate, maxElapsedMinutes, dataContext));
        }
Exemplo n.º 22
0
 public HotelsController(HotelDbContext context)
 {
     _context = context;
 }
Exemplo n.º 23
0
 public InvoicesRepository(HotelDbContext context)
 {
     database = context;
 }
Exemplo n.º 24
0
 public RoomRepository(HotelDbContext context, IAmenityManager amenities)
 {
     _context   = context;
     _amenities = amenities;
 }
Exemplo n.º 25
0
 public Repository(HotelDbContext context)
 {
     this.context = context;
 }
 public HotelRoomsController(ILogger <HotelRoomsController> logger, HotelDbContext hotelDbContext)
 {
     _logger         = logger;
     _hotelDbContext = hotelDbContext;
 }
 public DefaultLanguagesCreator(HotelDbContext context)
 {
     _context = context;
 }
Exemplo n.º 28
0
 public CustomerRepository(HotelDbContext context) : base(context)
 {
 }
Exemplo n.º 29
0
 public PaymentRepository(HotelDbContext context)
 {
     _context = context;
 }
Exemplo n.º 30
0
 public HotelTypeController(HotelDbContext _context)
 {
     context = _context;
 }
 public ActiveOrderRepository(HotelDbContext context) : base(context)
 {
 }
Exemplo n.º 32
0
 public GetAllRoomTypesQueryHandlerTests(QueryTestFixture fixture)
 {
     context = fixture.Context;
     mapper  = fixture.Mapper;
 }
Exemplo n.º 33
0
 public static List<IdentifyingCodeInfo> GetIdentifyingCodeByOrder(int orderId, string moduleName)
 {
     using (var context = new HotelDbContext())
     {
         return new IdentifyingCodeRepository(context).Get(
                 code => code.OrderId.Equals(orderId.ToString())
                 && code.ModuleName.Equals(moduleName)
                 ).ToList();
         ;
     }
 }
Exemplo n.º 34
0
 public CommentsRepository(HotelDbContext context) : base(context)
 {
 }
 public HotelController(HotelDbContext dbContext, IConfiguration config)
 {
     this.db            = dbContext;
     this.configuration = config;
 }
Exemplo n.º 36
0
 public AmenitiesController(HotelDbContext context)
 {
     _context = context;
 }
Exemplo n.º 37
0
        public static IList<IdentifyingCodeDetailSearchDTO> GetIdentifyingCodeDetailById(Guid identifyingCodeId, string moduleName)
        {
            if (Guid.Empty.Equals(identifyingCodeId) || string.IsNullOrEmpty(moduleName))
            {
                return null;
            }

            var identifyingCode = new IdentifyingCodeInfo() { IdentifyingCodeId = identifyingCodeId, ModuleName = moduleName };

            using (var context = new HotelDbContext())
            {
                IIdentifyingCodeRepository repository = new IdentifyingCodeRepository(context); //改造方向:依赖注入,彻底去除对Infrastructure层的依赖

                return repository.GetIdentifyingCodeDetailById(identifyingCode);
            }
        }
Exemplo n.º 38
0
 public RoomServices(HotelDbContext context, IRoomRepository roomRepository) : base(context)
 {
     RoomRepository = roomRepository;
 }