//*****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)); } }
//*****modified by hoangle 10-10-2019 //*****next modified by public IActionResult GetChartering(YachtCharteringRequestModel RequestModel) { var result = _yachtCharteringService.GetChartering(RequestModel); return(Ok(result)); }