//*****modified by hoangle 10-10-2019
        //*****next modified by
        public BaseResponse <YachtPricingPlanViewModel> GetPricingPlanDetailYachtFId(string yachtFId)
        {
            try
            {
                var yachtFIdde = Terminator.Decrypt(yachtFId).ToInt32();
                var result     = _aqYachtContext.YachtPricingPlans
                                 .Where(p => p.Deleted == false &&
                                        p.IsActivated == true &&
                                        p.YachtFid == yachtFIdde &&
                                        p.EffectiveDate <= DateTime.Now.Date &&
                                        (p.EffectiveEndDate == null || (p.EffectiveEndDate != null && p.EffectiveEndDate >= DateTime.Now.Date)) &&
                                        p.EffectiveDate == _aqYachtContext.YachtPricingPlans
                                        .Where(x => x.Deleted == false &&
                                               x.IsActivated == true &&
                                               x.YachtFid == yachtFIdde &&
                                               x.EffectiveDate <= DateTime.Now.Date &&
                                               (x.EffectiveEndDate == null || (x.EffectiveEndDate != null && x.EffectiveEndDate >= DateTime.Now.Date))
                                               ).OrderByDescending(o => o.EffectiveDate)
                                        .Select(i => i.EffectiveDate).FirstOrDefault()
                                        ).OrderByDescending(or => or.EffectiveDate)
                                 .Select(r => new YachtPricingPlanViewModel
                {
                    Id = Terminator.Encrypt(r.Id.ToString()),
                    PricingCategoryFid    = r.PricingCategoryFid,
                    PricingCategoryResKey = r.PricingCategoryResKey,
                    PlanName          = r.PlanName,
                    BasedPortLocation = r.BasedPortLocation,
                    YachtPortName     = r.YachtPortName,
                    Remark            = r.Remark,
                    Details           = r.Details.Select(rs => new YachtPricingPlanDetailViewModel
                    {
                        Id                = Terminator.Encrypt(rs.Id.ToString()),
                        PricingTypeFid    = rs.PricingTypeFid,
                        PricingTypeResKey = rs.PricingTypeResKey,
                        ContactOwner      = rs.ContactOwner,
                        Price             = rs.Price,
                        CultureCode       = rs.CultureCode,
                        CurrencyCode      = rs.CurrencyCode,
                        RealDayNumber     = AmountOfPriceType(rs.PricingTypeFid)
                    }
                                                         ).ToList()
                }).FirstOrDefault();

                if (result != null)
                {
                    return(BaseResponse <YachtPricingPlanViewModel> .Success(result));
                }
                else
                {
                    return(BaseResponse <YachtPricingPlanViewModel> .NoContent());
                }
            }
            catch (Exception ex)
            {
                #region log

                #endregion
                return(BaseResponse <YachtPricingPlanViewModel> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
示例#2
0
        public IActionResult Preview(long id, int languageId)
        {
            string encrypId = Terminator.Encrypt(id.ToString());
            string url      = $"{_commonSettings.FrontEnd_Domain}{_commonSettings.CMS_PostDetail_Preview}/{encrypId}/{languageId}";

            return(Redirect(url));
        }
示例#3
0
 public BaseResponse <PagedList <YachtTourPricingViewModel> > Search(int tourId, YachtTourPricingSearchModel model)
 {
     try
     {
         var pageSize  = model.PageSize > 0 ? model.PageSize : 10;
         var pageIndex = model.PageIndex > 0 ? model.PageIndex : 1;
         var query     = (from i in _db.YachtTourPricings
                          join y in _db.Yachts on i.YachtFid equals y.Id
                          where !i.Deleted && !y.Deleted && i.TourFid == tourId
                          select new YachtTourPricingViewModel()
         {
             Id = i.Id,
             YachtFid = Terminator.Encrypt(i.YachtFid.ToString()),
             YachtName = y.Name,
             TourFid = Terminator.Encrypt(i.TourFid.ToString()),
             TourPricingTypeResKey = i.TourPricingTypeResKey,
             EffectiveDate = i.EffectiveDate,
             EffectiveEndDate = i.EffectiveEndDate,
             TourFee = i.TourFee,
         }).OrderBy(x => x.YachtName).ThenBy(x => x.EffectiveDate);
         var result = new PagedList <YachtTourPricingViewModel>(query, pageIndex, pageSize);
         if (result != null)
         {
             return(BaseResponse <PagedList <YachtTourPricingViewModel> > .Success(result));
         }
         return(BaseResponse <PagedList <YachtTourPricingViewModel> > .BadRequest());
     }
     catch (Exception ex)
     {
         return(BaseResponse <PagedList <YachtTourPricingViewModel> > .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }
示例#4
0
 public static string EncryptObj(object obj)
 {
     return(Terminator.Encrypt(JsonConvert.SerializeObject(obj, new JsonSerializerSettings
     {
         NullValueHandling = NullValueHandling.Ignore
     })));
 }
示例#5
0
        public AutoMapperProfile()
        {
            //HotelAttributes
            CreateMap <HotelAttributes, HotelAttributeViewModel>();

            // HotelMerchantUsers
            CreateMap <HotelMerchantUsers, HotelMerchantUserViewModel>();

            // HotelReservationPaymentLogs
            CreateMap <HotelReservationPaymentLogs, HotelReservationPaymentLogViewModel>();

            // HotelReservationProcessingFees
            CreateMap <HotelReservationProcessingFees, HotelReservationProcessingFeeViewModel>();

            // HotelReservations
            CreateMap <HotelReservations, HotelReservationShowDashBoardModel>();
            CreateMap <HotelReservations, HotelReservationViewModel>();

            //HotelInventoryAttributes
            CreateMap <HotelInventoryAttributes, HotelInventoryAttributeViewModel>();

            //Hotels
            CreateMap <HotelCreateModel, Hotels>();
            CreateMap <Hotels, HotelViewModel>()
            .ForMember(viewModel => viewModel.InventoriesCount, entity => entity.MapFrom(k => k.Inventories.Count))
            .ForMember(viewModel => viewModel.Id, entity => entity.MapFrom(k => Terminator.Encrypt(k.Id.ToString())))
            .ForMember(viewModel => viewModel.MerchantFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.MerchantFid.ToString())));

            //HotelInformationDetails
            CreateMap <HotelInformationDetailCreateModel, HotelInformationDetails>();

            CreateMap <HotelInformationDetails, HotelInformationDetailViewModel>();
            //.ForMember(viewModel => viewModel.ActivatedDate, entity => entity.MapFrom(k => DateTimeHelper.ToString(k.ActivatedDate)));

            //HotelInformations
            CreateMap <HotelInformationCreateModel, HotelInformations>()
            .ForMember(viewModel => viewModel.HotelFid, entity => entity.MapFrom(k => Terminator.Decrypt(k.HotelFid.ToString())))
            .ForMember(entity => entity.ActivatedDate, createModel => createModel.MapFrom(k => k.ActivatedDate.ToDateTime()));
            //CreateMap<HotelInformations, HotelInformationViewModel>()
            //    .ForMember(viewModel => viewModel.ActivatedDate, entity => entity.MapFrom(k => DateTimeHelper.ToString(k.ActivatedDate)))
            //    .ForMember(viewModel => viewModel.HotelFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.HotelFid.ToString())))
            //    .ForMember(viewModel => viewModel.Id, entity => entity.MapFrom(k => Terminator.Encrypt(k.Id.ToString())));

            //Hotel Inventories
            CreateMap <HotelInventoryCreateModel, HotelInventories>();
            CreateMap <HotelInventories, HotelInventoryViewModel>()
            .ForMember(viewModel => viewModel.HotelFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.HotelFid.ToString())));

            #region HotelFileStreams

            CreateMap <HotelFileStreamCreateUpdateModel, HotelFileStreams>();
            CreateMap <HotelFileStreams, HotelFileStreamViewModel>();

            #endregion HotelFileStreams
        }
示例#6
0
        private void PreparingYachtLink(YachtItem item, YachtSearchModel searchModel)
        {
            string yachtId = Terminator.Encrypt(item.YachtID);

            var passParams = new YachtPassParamsModel(0, 0, searchModel);
            //string paramsData = passParams.EncryptData();
            string detailLink = Url.RouteUrl("YachtDetail", new { id = yachtId });

            detailLink += CommonHelper.ConvertToUrlParameter(passParams).ToLower();
            item.CustomProperties["DetailLink"] = detailLink;
        }
示例#7
0
        //*****modified by hoangle 10-10-2019
        //*****next modified by
        public BaseResponse <List <YachtMerchantProductInventoriesWithPriceViewModel> > GetPriceOfProductInventoryByArrayOfProductId(List <string> productId)
        {
            try
            {
                List <int> lstIntProuduceId = productId.Select(x => Terminator.Decrypt(x).ToInt32()).ToList();
                var        result           = (
                    from a in _aqYachtContext.YachtMerchantProductInventories

                    from productPricing in _aqYachtContext.YachtMerchantProductPricings
                    .Where(o => o.ProductFid == a.Id &&
                           o.Deleted == false &&
                           o.ProductFid == a.Id &&
                           o.EffectiveDate <= DateTime.Now.Date &&
                           (o.EffectiveEndDate == null || (o.EffectiveEndDate != null && o.EffectiveEndDate >= DateTime.Now.Date)) &&
                           o.EffectiveDate == _aqYachtContext.YachtMerchantProductPricings
                           .Where(x => x.ProductFid == a.Id &&
                                  x.EffectiveDate <= DateTime.Now.Date &&
                                  (x.EffectiveEndDate == null || (x.EffectiveEndDate != null && x.EffectiveEndDate >= DateTime.Now.Date))
                                  ).OrderByDescending(e => e.EffectiveDate)
                           .Select(i => i.EffectiveDate).FirstOrDefault()
                           ).DefaultIfEmpty().Take(1)

                    where
                    a.Deleted == false
                    // && a.IsActiveForSales == true
                    && lstIntProuduceId.Contains(a.Id)
                    select new YachtMerchantProductInventoriesWithPriceViewModel
                {
                    Id = Terminator.Encrypt(a.Id.ToString()),
                    UniqueId = a.UniqueId,
                    ProductCode = a.ProductCode,
                    ProductName = a.ProductName,
                    Price = productPricing == null ? 0 : productPricing.Price,
                    CultureCode = productPricing == null ? "" : productPricing.CultureCode,
                    CurrencyCode = productPricing == null ? "" : productPricing.CurrencyCode
                }
                    ).ToList();

                if (result != null)
                {
                    return(BaseResponse <List <YachtMerchantProductInventoriesWithPriceViewModel> > .Success(result));
                }
                else
                {
                    return(BaseResponse <List <YachtMerchantProductInventoriesWithPriceViewModel> > .NoContent());
                }
            }
            catch (Exception ex)
            {
                return(BaseResponse <List <YachtMerchantProductInventoriesWithPriceViewModel> > .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
示例#8
0
        //*****modified by hoangle 10-10-2019
        //*****next modified by
        public BaseResponse <List <YachtMerchantProductInventoriesWithPriceViewModel> > GetProductInventoryPricingByAdditionalFId(string additonalFId)
        {
            try
            {
                var responseAddId = Terminator.Decrypt(additonalFId).ToInt32();
                var result        = (from a in _aqYachtContext.YachtMerchantProductInventories

                                     join su in _aqYachtContext.YachtAdditionalServiceDetails
                                     on a.Id equals su.ProductFid


                                     let productPricing = (_aqYachtContext.YachtMerchantProductPricings.OrderByDescending(x => x.EffectiveDate).FirstOrDefault(x =>
                                                                                                                                                               x.Deleted == false &&
                                                                                                                                                               x.ProductFid == a.Id &&
                                                                                                                                                               x.EffectiveDate <= DateTime.Now.Date &&
                                                                                                                                                               (x.EffectiveEndDate == null || (x.EffectiveEndDate != null && x.EffectiveEndDate >= DateTime.Now.Date))
                                                                                                                                                               )
                                                           )
                                                          where

                                                          a.Deleted == false &&
                                                          a.IsActiveForSales == true &&
                                                          su.Deleted == false &&
                                                          su.AdditionalServiceFid == responseAddId &&
                                                          su.EffectiveDate <= DateTime.Now.Date &&
                                                          (su.EffectiveEndDate == null || (su.EffectiveEndDate != null && su.EffectiveEndDate >= DateTime.Now.Date))
                                                          select new YachtMerchantProductInventoriesWithPriceViewModel
                {
                    Id = Terminator.Encrypt(a.Id.ToString()),
                    UniqueId = a.UniqueId,
                    ProductCode = a.ProductCode,
                    ProductName = a.ProductName,
                    Price = productPricing == null ? 0 : productPricing.Price,
                    CultureCode = productPricing == null ? "" : productPricing.CultureCode,
                    CurrencyCode = productPricing == null ? "" : productPricing.CurrencyCode
                }
                                     ).ToList();

                if (result != null)
                {
                    return(BaseResponse <List <YachtMerchantProductInventoriesWithPriceViewModel> > .Success(result));
                }
                else
                {
                    return(BaseResponse <List <YachtMerchantProductInventoriesWithPriceViewModel> > .NoContent());
                }
            }
            catch (Exception ex)
            {
                return(BaseResponse <List <YachtMerchantProductInventoriesWithPriceViewModel> > .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
        //*****modified by hoangle 10-10-2019
        //*****next modified by
        public BaseResponse <string> Encrypt(int yachtFId)
        {
            try
            {
                var result = Terminator.Encrypt(yachtFId.ToString());

                if (result != null)
                {
                    return(BaseResponse <string> .Success(result));
                }
                else
                {
                    return(BaseResponse <string> .NoContent());
                }
            }
            catch (Exception ex)
            {
                return(BaseResponse <string> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
示例#10
0
        public BaseResponse <string> Create(YachtTourCreateModel model)
        {
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    var tour = GenerateYachtTourFromCreateModel(model);
                    if (tour == null)
                    {
                        return(BaseResponse <string> .BadRequest());
                    }
                    _db.YachtTours.Add(tour);
                    _db.SaveChanges();

                    var counter = new YachtTourCounters();
                    counter.YachtTourId          = tour.Id;
                    counter.YachtTourUniqueId    = UniqueIDHelper.GenarateRandomString(12);
                    counter.TotalViews           = 1000;
                    counter.TotalBookings        = 100;
                    counter.TotalSuccessBookings = 1000;
                    counter.TotalReviews         = 10000;
                    counter.TotalRecommendeds    = 100;
                    counter.TotalNotRecommendeds = 1;
                    _db.YachtTourCounters.Add(counter);
                    _db.SaveChanges();

                    transaction.Commit();
                    return(BaseResponse <string> .Success(Terminator.Encrypt(tour.Id.ToString())));
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    return(BaseResponse <string> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
                }
            }
        }
示例#11
0
        public MappingProfile()
        {
            #region Yacht

            CreateMap <Yachts, YachtCreateModel>();
            CreateMap <YachtCreateModel, Yachts>();
            CreateMap <YachtUpdateModel, Yachts>();

            #endregion Yacht

            #region YachtAttributeValue

            CreateMap <YachtAttributeValues, YachtAttributeCreateModel>();
            CreateMap <YachtAttributeCreateModel, YachtAttributeValues>();

            #endregion YachtAttributeValue

            #region YachtChartering

            CreateMap <YachtCharterings, YachtCharteringsViewModel>();
            CreateMap <YachtCharterings, YachtCharteringsDetailModel>();

            #endregion YachtChartering

            #region YachtCharteringProcessingFees

            CreateMap <YachtCharteringProcessingFees, YachtCharteringProcessingFeesViewModel>();

            #endregion YachtCharteringProcessingFees

            #region YachtCharteringPaymentLogs

            CreateMap <YachtCharteringPaymentLogs, YachtCharteringPaymentLogsViewModel>();

            #endregion YachtCharteringPaymentLogs

            #region YachtCharteringSchedules

            CreateMap <YachtCharteringSchedules, YachtCharteringSchedulesViewModel>();

            #endregion YachtCharteringSchedules

            #region YachtMerchantCharterFeeOptions

            CreateMap <YachtMerchantCharterFeeOptions, YachtMerchantCharterFeeOptionsViewModel>();

            #endregion YachtMerchantCharterFeeOptions

            #region YachtMerchantUsers

            CreateMap <YachtMerchantUsers, YachtMerchantUsersViewModel>();

            #endregion YachtMerchantUsers

            #region YachtCalendar

            //CreateMap<YachtCharterings, YachtCalendar>()
            //    .ForMember(model => model.Id, entity => entity.MapFrom(k => k.Id))
            //    .ForMember(model => model.YachtId, entity => entity.MapFrom(k => k.YachtFid))
            //    .ForMember(model => model.Start, entity => entity.MapFrom(k => k.CharterDateFrom))
            //    .ForMember(model => model.End, entity => entity.MapFrom(k => k.CharterDateTo))
            //    .ForMember(model => model.Status, entity => entity.MapFrom(k => 1));

            //CreateMap<YachtNonOperationDays, YachtCalendar>()
            //    .ForMember(model => model.Id, entity => entity.MapFrom(k => k.Id))
            //    .ForMember(model => model.YachtId, entity => entity.MapFrom(k =>k.YachtFid))
            //    .ForMember(model => model.Start, entity => entity.MapFrom(k => k.StartDate))
            //    .ForMember(model => model.End, entity => entity.MapFrom(k => k.EndDate))
            //    .ForMember(model => model.Status, entity => entity.MapFrom(k => 2));

            #endregion YachtCalendar

            #region YachtFileStream

            CreateMap <YachtFileStreams, YachtFileStreamViewModel>();
            CreateMap <YachtFileStreamCreateModel, YachtFileStreams>();
            CreateMap <YachtFileStreamUpdateModel, YachtFileStreams>();

            #endregion YachtFileStream

            #region YachtPricingPlans

            CreateMap <YachtPricingPlans, YachtPricingPlanCreateModel>();
            CreateMap <YachtPricingPlanCreateModel, YachtPricingPlans>();

            CreateMap <YachtPricingPlanDetails, YachtPricingPlanCreateModel>();
            CreateMap <YachtPricingPlanCreateModel, YachtPricingPlanDetails>();

            CreateMap <YachtPricingPlanInformations, YachtPricingPlanCreateModel>();
            CreateMap <YachtPricingPlanCreateModel, YachtPricingPlanInformations>();

            CreateMap <YachtPricingPlans, YachtPricingPlanViewModel>();
            CreateMap <YachtPricingPlanViewModel, YachtPricingPlans>();

            CreateMap <YachtPricingPlanDetails, YachtPricingPlanViewModel>();
            CreateMap <YachtPricingPlanViewModel, YachtPricingPlanDetails>();

            CreateMap <YachtPricingPlanInformations, YachtPricingPlanViewModel>();
            CreateMap <YachtPricingPlanViewModel, YachtPricingPlanInformations>();

            CreateMap <YachtPricingPlanDetailCreateModel, YachtPricingPlanDetails>();
            CreateMap <YachtPricingPlanDetails, YachtPricingPlanDetailCreateModel>();

            CreateMap <YachtMerchantProductVendors, YachtMerchantProductVendorViewModel>();
            CreateMap <YachtMerchantProductVendorCreateModel, YachtMerchantProductVendors>();
            CreateMap <YachtMerchantProductVendorUpdateModel, YachtMerchantProductVendors>();

            CreateMap <YachtPricingPlanInformationCreateModel, YachtPricingPlanInformations>();
            CreateMap <YachtPricingPlanInformations, YachtPricingPlanInformationCreateModel>();

            #endregion YachtPricingPlans

            #region YachtPort

            CreateMap <PortLocations, PortLocationViewModel>();

            #endregion YachtPort

            #region YachtTour

            CreateMap <YachtTours, YachTourViewModel>()
            .ForMember(model => model.Id, entity => entity.MapFrom(k => Terminator.Encrypt(k.Id.ToString())))
            .ForMember(model => model.MerchantFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.MerchantFid.ToString())));
            CreateMap <YachtTourCreateModel, YachtTours>();
            CreateMap <YachtTourUpdateModel, YachtTours>();

            CreateMap <YachtTourCategories, YachtTourCategoryViewModel>();

            #region YachtTourFileStream Models

            CreateMap <YachtTourFileStreamCreateModel, YachtTourFileStreams>();
            CreateMap <YachtTourFileStreams, YachtTourFileStreamViewModel>()
            .ForMember(model => model.YachtTourFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.YachtTourFid.ToString())));

            #endregion YachtTourFileStream Models

            CreateMap <YachtTourExternalRefLinks, YachtTourExternalRefLinkModel>()
            .ForMember(model => model.YachtTourFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.YachtTourFid.ToString())));

            #region YachtTourNonOperationDay Models

            CreateMap <YachtTourNonOperationDayCreateModel, YachtTourNonOperationDays>()
            .ForMember(model => model.YachtTourFid, entity => entity.MapFrom(k => Terminator.Decrypt(k.YachtTourFid).ToInt32()))
            .ForMember(model => model.YachtFid, entity => entity.MapFrom(k => Terminator.Decrypt(k.YachtFid).ToInt32()));
            CreateMap <YachtTourNonOperationDays, YachtTourNonOperationDayViewModel>()
            .ForMember(model => model.YachtTourFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.YachtTourFid.ToString())))
            .ForMember(model => model.YachtFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.YachtFid.ToString())));

            #endregion YachtTourNonOperationDay Models

            #region YachtTourCounter Models

            CreateMap <YachtTourCounters, YachtTourCounterViewModel>()
            .ForMember(model => model.YachtTourId, entity => entity.MapFrom(k => Terminator.Encrypt(k.YachtTourId.ToString())));
            CreateMap <YachtTourCounterCreateModel, YachtTourCounters>()
            .ForMember(model => model.YachtTourId, entity => entity.MapFrom(k => Terminator.Decrypt(k.YachtTourId).ToInt32()));

            #endregion YachtTourCounter Models

            #region YachtTourOperationDetail Models

            CreateMap <YachtTourOperationDetails, YachtTourOperationDetailViewModel>()
            .ForMember(model => model.TourFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.TourFid.ToString())))
            .ForMember(model => model.YachtFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.YachtFid.ToString())))
            .ForMember(model => model.MerchantFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.MerchantFid.ToString())));
            CreateMap <YachtTourOperationDetailCreateModel, YachtTourOperationDetails>()
            .ForMember(model => model.TourFid, entity => entity.MapFrom(k => Terminator.Decrypt(k.TourFid).ToInt32()))
            .ForMember(model => model.YachtFid, entity => entity.MapFrom(k => Terminator.Decrypt(k.YachtFid).ToInt32()))
            .ForMember(model => model.MerchantFid, entity => entity.MapFrom(k => Terminator.Decrypt(k.MerchantFid).ToInt32()));

            #endregion YachtTourOperationDetail Models

            #region YachtTourAttributes Models

            CreateMap <YachtTourAttributes, YachtTourAttributeViewModel>();

            #endregion YachtTourAttributes Models

            #region YachtTourAttributeValue Models

            CreateMap <YachtTourAttributeValues, YachtTourAttributeValueViewModel>()
            .ForMember(model => model.YachtTourFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.YachtTourFid.ToString())));
            CreateMap <YachtTourAttributeValueCreateModel, YachtTourAttributeValues>()
            .ForMember(model => model.YachtTourFid, entity => entity.MapFrom(k => Terminator.Decrypt(k.YachtTourFid).ToInt32()));

            #endregion YachtTourAttributeValue Models

            #region YachtTourPricings Models

            CreateMap <YachtTourPricings, YachtTourPricingViewModel>()
            .ForMember(model => model.TourFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.TourFid.ToString())))
            .ForMember(model => model.YachtFid, entity => entity.MapFrom(k => Terminator.Encrypt(k.YachtFid.ToString())));

            #endregion YachtTourPricings Models

            #region YachtTourInformations

            CreateMap <YachtTourInformationDetails, YachtTourInformationUpdateDetailModel>();

            #endregion YachtTourInformations

            #endregion YachtTour

            #region YachtTourCharterPaymentLogs
            CreateMap <YachtTourCharterPaymentLogs, YachtTourCharterPaymentLogsViewModel>();
            #endregion

            #region YachtTourCharterProcessingFees

            CreateMap <YachtTourCharterProcessingFees, YachtTourCharterProcessingFeesViewModel>();
            #endregion

            # region YachtTourCharterSchedules
        //*****modified by hoangle 10-10-2019
        //*****next modified by
        //*****using Yacht/CartPayment
        public BaseResponse <SaveCharterPaymentResponseViewModel> SaveChartering(SaveBookingRequestModel requestModel, string PaymentMethod)
        {
            #region initalize logging
            string errCode = "0";
            SaveCharterPaymentResponseViewModel errGlobal = new SaveCharterPaymentResponseViewModel();
            #endregion

            #region logging Subject
            string dataSubjectLogging = "";

            errGlobal.Name       = "SavePaymentTrip";
            errGlobal.Value      = dataSubjectLogging;
            errGlobal.ResuldCode = errCode;
            errGlobal.Id         = "0";
            errGlobal.UniqueId   = "";
            #endregion
            try
            {
                var redisCartRequestModel = requestModel.RedisCartRequestModel;
                var bookingRequestModel   = requestModel.BookingRequestModel;
                var value = _distributedCache.GetString(redisCartRequestModel.Key);
                if (value != null)
                {
                    var lstRedisStorage = JsonConvert.DeserializeObject <List <RedisStorage> >(value);

                    //requestModel.HashKey ==> Dining or Yacht or other...
                    var RedisStorageModel = lstRedisStorage.FirstOrDefault(k => k.Domain == redisCartRequestModel.HashKey);
                    #region DOMAIN
                    if (RedisStorageModel != null)// DOMAIN IS  EXIST
                    {
                        var result = RedisStorageModel.PackageStorage;
                        if (result != null)
                        {
                            List <YachtPackageServiceModel> lstYachtPackage = result.Where(x => redisCartRequestModel.itemList.Contains(x.YachtId)).Select(i => i).ToList();

                            if (lstYachtPackage != null)
                            {
                                ///Foreach Yacht choosed
                                foreach (YachtPackageServiceModel yachtItem in lstYachtPackage)
                                {
                                    #region CALCULATION

                                    MerchantPaymentPackageViewModel            responsePackageModel  = new MerchantPaymentPackageViewModel();
                                    List <MerchantPaymentEachPackageViewModel> lstProductInventories = new List <MerchantPaymentEachPackageViewModel>();
                                    #region logging Subject
                                    if (dataSubjectLogging != "")
                                    {
                                        dataSubjectLogging += ",";
                                    }
                                    dataSubjectLogging += "{";
                                    dataSubjectLogging += $"YachtId:{yachtItem.YachtId},";
                                    dataSubjectLogging += $"Passenger:{yachtItem.Passenger },";
                                    dataSubjectLogging += $"CheckIn:{yachtItem.CheckIn },";
                                    dataSubjectLogging += $"CheckOut:{yachtItem.CheckOut },";
                                    string ErrorCode        = "0";
                                    string ErrorDescription = "";
                                    string ErrorGlobalPackageDescription = "";
                                    #endregion
                                    try
                                    {
                                        #region YACHT
                                        var yachtFIdde = Terminator.Decrypt(yachtItem.YachtId).ToInt32();

                                        double dbYachtFee        = 0;
                                        string yachtCultureCode  = "";
                                        string yachtCurrencyCode = "";

                                        #region NUMBER OF DAY OR WEEK
                                        int bookingDayNumber = GlobalMethod.BookingDayNumber(yachtItem.CheckIn, yachtItem.CheckOut);

                                        #region GET PRICE
                                        var responsePricingPlanDetail = _yachtPricingPlanDetailService.GetPricingPlanDetailYachtFId(yachtItem.YachtId);
                                        if (responsePricingPlanDetail != null && responsePricingPlanDetail.IsSuccessStatusCode && responsePricingPlanDetail.ResponseData != null)
                                        {
                                            if (responsePricingPlanDetail.ResponseData.Details != null)
                                            {
                                                var priceDetail = responsePricingPlanDetail.ResponseData.Details.OrderByDescending(x => x.PricingTypeFid).FirstOrDefault();
                                                if (priceDetail != null)
                                                {
                                                    yachtCultureCode  = priceDetail.CultureCode;
                                                    yachtCurrencyCode = priceDetail.CurrencyCode;
                                                }
                                                GlobalMethod.GetPriceRecuse(responsePricingPlanDetail.ResponseData.Details, bookingDayNumber, ref dbYachtFee);
                                            }
                                        }

                                        #endregion

                                        responsePackageModel.Id            = yachtItem.YachtId;
                                        responsePackageModel.Passenger     = yachtItem.Passenger;
                                        responsePackageModel.YachtTotal    = dbYachtFee;
                                        responsePackageModel.Total         = dbYachtFee;
                                        responsePackageModel.PackageTotal  = 0;
                                        responsePackageModel.DiscountTotal = 0;
                                        #endregion

                                        /**INSERT INTO CHARTERING**/

                                        #region YachtPort Infomation
                                        var responseYachtPort = (
                                            from p in _aqYachtContext.YachtPorts
                                            .Where(k => k.YachtFid == yachtFIdde &&
                                                   k.Deleted == false &&
                                                   k.EffectiveDate <= DateTime.Now.Date &&
                                                   k.IsActivated == true &&
                                                   k.EffectiveDate == _aqYachtContext.YachtPorts
                                                   .Where(o => o.YachtFid == yachtFIdde &&
                                                          o.Deleted == false &&
                                                          o.EffectiveDate <= DateTime.Now.Date &&
                                                          o.IsActivated == true
                                                          )
                                                   .OrderByDescending(x => x.EffectiveDate)
                                                   .Select(i => i.EffectiveDate).FirstOrDefault()
                                                   ).DefaultIfEmpty().Take(1)

                                            select p
                                            ).FirstOrDefault();
                                        #endregion

                                        #region YachtInfomation
                                        bool   isCrewmember = false;
                                        Yachts yachtOjb     = _aqYachtContext.Yachts.FirstOrDefault(x => x.Id == yachtFIdde);
                                        if (yachtOjb != null)
                                        {
                                            if (yachtOjb.CrewMembers > 0)
                                            {
                                                isCrewmember = true;
                                            }
                                        }
                                        #endregion

                                        #region INSERT INTO CHARTERING
                                        YachtCharterings charteringModel = new YachtCharterings();
                                        charteringModel.YachtFid = yachtFIdde;

                                        charteringModel.SourceFid    = 1;
                                        charteringModel.SourceResKey = "SOURCEAQBOOKINGS";
                                        charteringModel.UniqueId     = UniqueIDHelper.GenarateRandomString(12);

                                        //customer
                                        charteringModel.CustomerName     = bookingRequestModel.NameOfUser;
                                        charteringModel.ReservationEmail = bookingRequestModel.EmailOfUser;
                                        bool isUerExisting = false;
                                        if (bookingRequestModel.IsEmailExist != 0)
                                        {
                                            isUerExisting = true;
                                        }
                                        charteringModel.IsExistingCustomer = isUerExisting;

                                        if (bookingRequestModel.IdOfUser.Trim() != "")
                                        {
                                            charteringModel.CustomerFid = new Guid(bookingRequestModel.IdOfUser.Trim());
                                        }
                                        charteringModel.ContactNo       = bookingRequestModel.ContactNo;
                                        charteringModel.Passengers      = yachtItem.Passenger;
                                        charteringModel.CharterDateFrom = DateTime.Now;
                                        charteringModel.CharterDateTo   = DateTime.Now;
                                        charteringModel.BookingDate     = DateTime.Now;

                                        //yacht port
                                        if (responseYachtPort != null)
                                        {
                                            charteringModel.YachtPortFid  = responseYachtPort.PortFid;
                                            charteringModel.YachtPortName = responseYachtPort.PortName;
                                        }
                                        else
                                        {
                                            charteringModel.YachtPortFid  = -1;
                                            charteringModel.YachtPortName = "";
                                        }


                                        charteringModel.HaveCrewsMember = isCrewmember;
                                        charteringModel.CultureCode     = yachtCultureCode;
                                        charteringModel.CurrencyCode    = yachtCurrencyCode;

                                        charteringModel.StatusFid    = Convert.ToInt32(YachtCharterStatusEnum.Waiting);
                                        charteringModel.StatusResKey = "WAITINGPAYMENT";
                                        charteringModel.Processed    = false;

                                        _aqYachtContext.YachtCharterings.Add(charteringModel);
                                        _aqYachtContext.SaveChanges();
                                        long charteringModelId = charteringModel.Id;
                                        #region logging
                                        errGlobal.Id       = Terminator.Encrypt(charteringModelId.ToString());
                                        errGlobal.UniqueId = charteringModel.UniqueId;

                                        #endregion

                                        #endregion

                                        #endregion

                                        #region PACKAGE
                                        bool isPackageAddition = false;
                                        List <MerchantProductInventoriesModel> lstProductPackage = yachtItem.ProductPackage;
                                        double dbPackageFee           = 0;
                                        double dbTotalFinalValue      = 0;
                                        double dbTotalGrandTotalValue = 0;
                                        double dbTotalDiscountPackage = 0;

                                        if (lstProductPackage != null)
                                        {
                                            List <string> lstProductId           = lstProductPackage.Select(x => x.productInventoryFId).ToList();
                                            var           responsePriceOfProduct = _yachtMerchantProductInventoryService.GetPriceOfProductInventoryByArrayOfProductId(lstProductId);
                                            if (responsePriceOfProduct != null && responsePriceOfProduct.IsSuccessStatusCode && responsePriceOfProduct.ResponseData != null)
                                            {
                                                foreach (MerchantProductInventoriesModel proItem in lstProductPackage)
                                                {
                                                    #region logging Detail
                                                    //SaveCharterPaymentDetailViewModel errDetail = new SaveCharterPaymentDetailViewModel();
                                                    string dataSubLogging = "";
                                                    dataSubLogging += "{";
                                                    dataSubLogging += $"ProductInventoryFId:\"{proItem.productInventoryFId }\",";
                                                    dataSubLogging += $"Quantity:{ proItem.quantity}";
                                                    string ErrorDetailCode = "0";
                                                    string ErrorDetailPackageDescription = "";
                                                    #endregion
                                                    try
                                                    {
                                                        YachtMerchantProductInventoriesWithPriceViewModel reponseProduct = responsePriceOfProduct.ResponseData.FirstOrDefault(x => x.Id.Trim() == proItem.productInventoryFId.Trim());
                                                        if (reponseProduct != null)
                                                        {
                                                            MerchantPaymentEachPackageViewModel objPackageWithPrice = new MerchantPaymentEachPackageViewModel();

                                                            /**INSERT INTO  CHARTERINGDETAIL**/
                                                            #region INSERT INTO  CHARTERINGDETAIL
                                                            YachtCharteringDetails charteringDetailModel = new YachtCharteringDetails();
                                                            charteringDetailModel.CharteringFid  = charteringModelId;
                                                            charteringDetailModel.YachtFid       = yachtFIdde;
                                                            charteringDetailModel.ItemTypeFid    = 1;
                                                            charteringDetailModel.ItemTypeResKey = "VENDORSERVICES";

                                                            charteringDetailModel.RefFid = Terminator.Decrypt(reponseProduct.Id).ToInt32();

                                                            charteringDetailModel.ItemName        = reponseProduct.ProductName;
                                                            charteringDetailModel.CultureCode     = reponseProduct.CultureCode;
                                                            charteringDetailModel.CurrencyCode    = reponseProduct.CurrencyCode;
                                                            charteringDetailModel.OrderAmount     = proItem.quantity;
                                                            charteringDetailModel.DiscountedValue = 0;
                                                            charteringDetailModel.OriginalValue   = reponseProduct.Price;
                                                            charteringDetailModel.FinalValue      = reponseProduct.Price - charteringDetailModel.DiscountedValue;
                                                            charteringDetailModel.GrandTotalValue = GlobalMethod.PackageTotal(charteringDetailModel.FinalValue, proItem.quantity);
                                                            // charteringDetailModel.FinalValue = charteringDetailModel.GrandTotalValue - charteringDetailModel.DiscountedValue;

                                                            _aqYachtContext.YachtCharteringDetails.Add(charteringDetailModel);

                                                            _aqYachtContext.SaveChanges();
                                                            #endregion
                                                            dbTotalFinalValue      += charteringDetailModel.FinalValue;
                                                            dbTotalGrandTotalValue += charteringDetailModel.GrandTotalValue;
                                                            dbPackageFee           += GlobalMethod.PackageTotal(charteringDetailModel.OriginalValue, proItem.quantity);
                                                            dbTotalDiscountPackage += GlobalMethod.PackageTotal(charteringDetailModel.DiscountedValue, proItem.quantity);
                                                            isPackageAddition       = true;
                                                        }
                                                        ErrorDetailCode = "1";
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        #region logging add detail to errGlobal variable
                                                        ErrorDetailCode = "-1";
                                                        ErrorDetailPackageDescription = ex.Message.ToString();
                                                        #endregion
                                                    }
                                                    dataSubLogging += $"ErrorCode:{ ErrorDetailCode}";
                                                    dataSubLogging += $"ErrorDescription:{ ErrorDetailPackageDescription}";
                                                    dataSubLogging += "}";
                                                    #region ADD PACKAGE DETAIL ERROR TO THE YACHT ERROR.
                                                    if (ErrorGlobalPackageDescription != "")
                                                    {
                                                        ErrorGlobalPackageDescription += ",";
                                                    }
                                                    ErrorGlobalPackageDescription += dataSubLogging;
                                                    #endregion
                                                }

                                                responsePackageModel.PackageTotal  = dbPackageFee;
                                                responsePackageModel.DiscountTotal = responsePackageModel.DiscountTotal + dbTotalDiscountPackage;

                                                responsePackageModel.Total             = (responsePackageModel.PackageTotal + responsePackageModel.Total);
                                                responsePackageModel.lstPaymentPackage = lstProductInventories;
                                            }
                                        }
                                        #endregion

                                        responsePackageModel.PrePaidRate  = 0.5;
                                        responsePackageModel.PrepaidValue = responsePackageModel.PrePaidRate * responsePackageModel.Total;

                                        //***UPDATE CHARTERING PRICING
                                        var newChartering = _aqYachtContext.YachtCharterings.FirstOrDefault(x => x.Id == charteringModelId);
                                        if (newChartering != null)
                                        {
                                            newChartering.HaveAdditionalServices = isPackageAddition;
                                            newChartering.PrepaidRate            = responsePackageModel.PrePaidRate;
                                            newChartering.PrepaidValue           = responsePackageModel.PrepaidValue;
                                            newChartering.GrandTotalValue        = responsePackageModel.Total - responsePackageModel.DiscountTotal;
                                            newChartering.DiscountedValue        = responsePackageModel.DiscountTotal;
                                            newChartering.OriginalValue          = responsePackageModel.Total;

                                            _aqYachtContext.SaveChanges();
                                        }

                                        //****INSERT TO PAYMENTLOGS TABLE
                                        YachtCharteringPaymentLogs paymentLogs = new YachtCharteringPaymentLogs();
                                        paymentLogs.CharteringFid = charteringModelId;

                                        //call api payment from Mr Long
                                        paymentLogs.PaymentBy     = "";
                                        paymentLogs.PaymentRef    = "";
                                        paymentLogs.PaymentMethod = PaymentMethod;

                                        paymentLogs.PaymentDate   = DateTime.Now;
                                        paymentLogs.PaymentAmount = responsePackageModel.PrepaidValue;
                                        paymentLogs.CultureCode   = yachtCultureCode;
                                        paymentLogs.CurrencyCode  = yachtCurrencyCode;
                                        paymentLogs.StatusFid     = Convert.ToInt32(YachtCharterStatusEnum.Waiting);//wating for payment
                                        _aqYachtContext.YachtCharteringPaymentLogs.Add(paymentLogs);
                                        _aqYachtContext.SaveChanges();
                                        #endregion

                                        ErrorCode = "1";
                                    }
                                    catch (Exception ex)
                                    {
                                        ErrorCode        = "-1";
                                        ErrorDescription = ex.Message.ToString();
                                    }
                                    dataSubjectLogging += $"ErrorCode:{ErrorCode },";
                                    dataSubjectLogging += $"ErrorDescription:{ErrorDescription }";
                                    dataSubjectLogging += $"ErrorDetail:{ErrorGlobalPackageDescription }";
                                    dataSubjectLogging += "}";
                                }
                                errGlobal.Value = dataSubjectLogging;
                            }
                        }
                    }
                    #endregion
                }

                #region logging
                errCode = "1";
                errGlobal.ResuldCode = errCode;
                #endregion

                return(BaseResponse <SaveCharterPaymentResponseViewModel> .Success(errGlobal));
            }
            catch (Exception ex)
            {
                errCode = "-1";
                errGlobal.ResuldCode = errCode;
                errGlobal.Describes  = ex.Message.ToString();
                return(BaseResponse <SaveCharterPaymentResponseViewModel> .InternalServerError(errGlobal, ex.Message));
            }
        }
        //*****modified by hoangle 10-10-2019
        //*****next modified by
        public BaseResponse <SaveCharterPaymentResponseViewModel> UpdateStatusCharterPrivatePayment(CharteringUpdateStatusModel charteringModel)
        {
            #region initalize logging
            string errCode = "0";
            SaveCharterPaymentResponseViewModel errGlobal = new SaveCharterPaymentResponseViewModel();
            #endregion
            try
            {
                #region logging Subject
                string dataSubjectLogging = "";
                errGlobal.Value      = dataSubjectLogging;
                errGlobal.ResuldCode = errCode;
                errGlobal.UniqueId   = charteringModel.UniqueId;
                #endregion
                var responsecharter = _aqYachtContext.YachtCharterings.FirstOrDefault(x => x.UniqueId.Trim().ToLower() == charteringModel.UniqueId.Trim().ToLower());
                if (responsecharter != null)
                {
                    if (charteringModel.StatusFId == Convert.ToInt32(YachtCharterStatusEnum.Waiting))
                    {
                        responsecharter.StatusResKey = "WAITINGPAYMENT";
                    }
                    if (charteringModel.StatusFId == Convert.ToInt32(YachtCharterStatusEnum.Paid))
                    {
                        responsecharter.StatusResKey = "PAID";
                    }
                    if (charteringModel.StatusFId == Convert.ToInt32(YachtCharterStatusEnum.Pending))
                    {
                        responsecharter.StatusResKey = "PENDING";
                    }
                    if (charteringModel.StatusFId == Convert.ToInt32(YachtCharterStatusEnum.Accepted))
                    {
                        responsecharter.StatusResKey = "ACCEPTED";
                    }
                    if (charteringModel.StatusFId == Convert.ToInt32(YachtCharterStatusEnum.Rejected))
                    {
                        responsecharter.StatusResKey = "REJECTED";
                    }
                    if (charteringModel.StatusFId == Convert.ToInt32(YachtCharterStatusEnum.Cancelled))
                    {
                        responsecharter.StatusResKey = "CANCELLED";
                    }
                    if (charteringModel.StatusFId == Convert.ToInt32(YachtCharterStatusEnum.Completed))
                    {
                        responsecharter.StatusResKey = "COMPLETED";
                    }

                    responsecharter.StatusFid = charteringModel.StatusFId;
                    _aqYachtContext.SaveChanges();
                    errGlobal.UniqueId = responsecharter.UniqueId;
                    errGlobal.Id       = Terminator.Encrypt(responsecharter.Id.ToString());
                }

                #region logging
                errCode = "1";
                errGlobal.ResuldCode = errCode;
                #endregion

                return(BaseResponse <SaveCharterPaymentResponseViewModel> .Success(errGlobal));
            }
            catch (Exception ex)
            {
                errCode = "-1";
                errGlobal.ResuldCode = errCode;
                errGlobal.Describes  = ex.Message.ToString();
                return(BaseResponse <SaveCharterPaymentResponseViewModel> .InternalServerError(errGlobal, ex.Message));
            }
        }