//*****modified by hoangle 10-10-2019
        //*****next modified by
        public BaseResponse <YachtCharteringViewModel> GetChartering(YachtCharteringRequestModel RequestModel)
        {
            YachtCharteringViewModel chartering = new YachtCharteringViewModel();

            try
            {
                DateTime checkinDate  = DateTime.Now;
                DateTime checkoutDate = DateTime.Now;
                if (RequestModel.CheckIn != "" && RequestModel.CheckOut != "")
                {
                    checkinDate  = DateTime.Parse(RequestModel.CheckIn);
                    checkoutDate = DateTime.Parse(RequestModel.CheckOut);
                }

                var resYachtFId = Terminator.Decrypt(RequestModel.YachtFId).ToInt32();

                chartering = _aqYachtContext.YachtCharterings
                             .Where(k => k.YachtFid == resYachtFId &&
                                    (RequestModel.StatusId == null || RequestModel.StatusId.Count > 0 || (RequestModel.StatusId.Contains(k.StatusFid))) &&
                                    ((RequestModel.CheckIn == "" && RequestModel.CheckOut == "") ||
                                     (checkinDate >= k.CharterDateFrom && checkinDate <= k.CharterDateTo) || (checkoutDate >= k.CharterDateFrom && checkoutDate <= k.CharterDateTo)

                                     || (checkinDate <= k.CharterDateFrom && checkoutDate >= k.CharterDateTo)
                                    )
                                    )
                             .Select(i => _mapper.Map <YachtCharterings, YachtCharteringViewModel>(i)).FirstOrDefault();

                return(BaseResponse <YachtCharteringViewModel> .Success(chartering));
            }
            catch (Exception ex)
            {
                return(BaseResponse <YachtCharteringViewModel> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
示例#2
0
        /// <summary>
        /// Load yacht book detail by Tuan Kiet
        /// </summary>
        /// <returns></returns>
        public IActionResult Checkout()
        {
            YachtCharteringViewModel res = new YachtCharteringViewModel();

            if (WorkContext.IsAuthentication && HttpContext.Session.Keys.Count() > 0)
            {
                res = _yachtBookingService.GetCharterByReservationEmail(WorkContext.CurentUser.Email);
                //ViewBag.modelReservation = HttpContext.Session.GetObject<YachtBookingModel>("YachtCart");
            }
            return(View("Checkout", res));
        }
        //*****modified by hoangle 10-10-2019
        //*****next modified by
        public BaseResponse <YachtCharteringViewModel> GetCharteringByUniqueId(string uniqueId)
        {
            YachtCharteringViewModel chartering = new YachtCharteringViewModel();

            try
            {
                chartering = _aqYachtContext.YachtCharterings
                             .Where(k => k.UniqueId == uniqueId && k.StatusFid == Convert.ToInt32(YachtCharterStatusEnum.Waiting) && k.Processed == false)
                             .Select(i => _mapper.Map <YachtCharterings, YachtCharteringViewModel>(i)).FirstOrDefault();

                return(BaseResponse <YachtCharteringViewModel> .Success(chartering));
            }
            catch (Exception ex)
            {
                return(BaseResponse <YachtCharteringViewModel> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }