private async void GetTravelsRequest()
        {
            try
            {
                List <Travel> travelList = new List <Travel>();
                TravelModel   model      = await App.Client.GetTravels();

                if (model.status == "true")
                {
                    for (int i = 0; i < model.feeds.Count; i++)
                    {
                        var travel = new Travel()
                        {
                            id        = model.feeds[i].id,
                            active    = model.feeds[i].active,
                            gezi      = model.feeds[i].gezi,
                            image     = model.filebase + model.feeds[i].image,
                            pdf       = model.feeds[i].pdf,
                            priority  = model.feeds[i].priority,
                            shareLink = model.feeds[i].shareLink
                        };

                        travelList.Add(travel);
                    }

                    travelListView.ItemsSource = travelList;
                }
            }

            catch (Exception)
            {
            }
        }
Beispiel #2
0
        public List <TravelModel> EntitytoModel(List <Travel> entities)
        {
            List <TravelModel> models = new List <TravelModel>();

            foreach (var entity in entities)
            {
                TravelModel model = new TravelModel();
                model.Company       = new CompanyModel();
                model.DepartureDate = new DepartureDateModel();
                model.ArrivalDate   = new ArrivalDate();

                model.objectId          = entity.ObjectId;
                model.Company.Name      = entity.Company;
                model.Origin            = entity.Origin;
                model.Destination       = entity.Destination;
                model.DepartureDate.iso = entity.DepartureDate;
                model.ArrivalDate.iso   = entity.ArrivalDate;
                model.BusClass          = entity.BussClass;
                model.createdAt         = entity.CreatedAt;
                model.updatedAt         = entity.UpdatedAt;
                model.Price             = entity.Price;
                models.Add(model);
            }
            return(models);
        }
        public ActionResult EditTravel(TravelModel travelModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                travelProcessor.Edit(travelModel, travelModel.Id);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Error al editar el viaje - " + ex.Message);
                return(View());
            }
        }
        public ActionResult CreateTravel(TravelModel travelModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                travelModel.AgencyID = 1;
                travelProcessor.Create(travelModel);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Error al agregar el viaje - " + ex.Message);
                return(View());
            }
        }
        public ActionResult EditTravel(int Id)
        {
            ViewBag.Message = "Edición del viaje seleccionado";

            Object travelObjectDB   = travelProcessor.GetModelById(Id);
            Travel selectedTravelDB = travelObjectDB as Travel;

            TravelModel travelModel = new TravelModel
            {
                Id          = selectedTravelDB.Id,
                AgencyID    = selectedTravelDB.AgencyID,
                Titular     = selectedTravelDB.Titular,
                StartDate   = selectedTravelDB.StartDate,
                EndDate     = selectedTravelDB.EndDate,
                TotalCost   = selectedTravelDB.TotalCost,
                Description = selectedTravelDB.Description,
                Notes       = selectedTravelDB.Notes
            };

            return(View(travelModel));
        }
Beispiel #6
0
        public long SaveTravelIns(TravelModel objTravelIns)
        {
            long returnCode = -1;

            using (TransactionScope transactionScope = new TransactionScope())
            {
                try
                {
                    returnCode = objMotorAppDAL.SaveTravelIns(objTravelIns);
                    transactionScope.Complete();
                    transactionScope.Dispose();
                }
                catch (Exception ex)
                {
                    transactionScope.Dispose();
                    throw ex;
                }

                return(returnCode);
            }
        }
Beispiel #7
0
        public TravelModel GetTravelList(TravelQueryModel query)
        {
            TravelModel result = new TravelModel();

            result.DataList = new List <TravelDataModel>();

            TravelModel fltTravelModel = GetFlight(query);
            TravelModel traTravelModel = GetTrain(query);

            if (fltTravelModel != null && fltTravelModel.DataList != null && fltTravelModel.DataList.Count > 0)
            {
                result.DataList.AddRange(fltTravelModel.DataList);
            }

            if (traTravelModel != null && traTravelModel.DataList != null && traTravelModel.DataList.Count > 0)
            {
                result.DataList.AddRange(traTravelModel.DataList);
            }

            result.DataList = result.DataList.OrderBy(n => n.DTime).ToList();

            return(result);
        }
Beispiel #8
0
        public TravelResponseViewModel GetTravel(TravelRequestViewModel request)
        {
            ContactInfoModel contactInfoModel = _getContactBll.GetCorpContactByCid(request.Cid);

            if (contactInfoModel == null)
            {
                throw new Exception("无法查询到对应的联系人信息");
            }
            //1.查询机场信息
            SearchCityAportModel aportModel = _getCityForFlightServiceBll.SearchAirport(new List <string>()
            {
                "N"
            });
            TravelQueryModel query = Mapper.Map <TravelRequestViewModel, TravelQueryModel>(request);

            query.AportInfo = aportModel;
            query.ContactId = contactInfoModel.ContactId;

            TravelModel travelModel = _getTravelServiceBll.GetTravelList(query);

            TravelResponseViewModel viewModel = Mapper.Map <TravelModel, TravelResponseViewModel>(travelModel);

            return(viewModel);
        }
Beispiel #9
0
        private TravelModel GetFlight(TravelQueryModel query)
        {
            if (!query.ContactId.HasValue)
            {
                throw new Exception("请传入ContactId参数");
            }

            TravelModel travel = new TravelModel();

            travel.DataList = new List <TravelDataModel>();

            List <string> orderstatusList = new List <string>()
            {
                "N", "C", "W"
            };

            List <SearchCityModel>    cityModels    = query.AportInfo.CountryList.SelectMany(n => n.CityList).ToList();
            List <SearchAirportModel> airportModels = cityModels.SelectMany(n => n.AirportList).ToList();

            int      contactId = query.ContactId.Value;
            DateTime nowTime   = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));

            List <string>          indexList        = new List <string>();
            List <int>             orderIdList      = new List <int>();
            List <TravelDataModel> travelDataModels = new List <TravelDataModel>();

            #region 机票正单行程

            List <FltFlightEntity> flightList = (from flight in base.Context.Set <FltFlightEntity>().AsNoTracking()
                                                 join passenger in Context.Set <FltPassengerEntity>().AsNoTracking() on flight.OrderId equals
                                                 passenger.OrderId
                                                 join order in Context.Set <FltOrderEntity>().AsNoTracking() on flight.OrderId equals order.OrderId
                                                 where
                                                 flight.TackoffTime >= nowTime && !orderstatusList.Contains(order.Orderstatus) &&
                                                 (order.ProcessStatus & 8) == 8 &&
                                                 passenger.Contactid == contactId
                                                 select flight).Distinct().ToList();


            List <FltFlightModel> flightModels = Mapper.Map <List <FltFlightEntity>, List <FltFlightModel> >(flightList);
            flightModels.ForEach(n =>
            {
                SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode == n.Dport);
                if (airportModel != null)
                {
                    n.DportName = airportModel.AirportName;
                    SearchCityModel cityModel = cityModels.Find(x => x.CityCode == airportModel.CityCode);
                    n.DportCity = cityModel.CityName;
                }

                SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode == n.Aport);
                if (airportModel2 != null)
                {
                    n.AportName = airportModel2.AirportName;
                    SearchCityModel cityModel2 = cityModels.Find(x => x.CityCode == airportModel2.CityCode);
                    n.AportCity = cityModel2.CityName;
                }

                orderIdList.Add(n.OrderId);
            });

            List <TravelDataModel> flightTravelDataModels = (from n in flightModels
                                                             select new TravelDataModel()
            {
                Type = OrderSourceTypeEnum.Flt.ToString(),
                AName = n.AportName,
                DName = n.DportName,
                ATime = n.ArrivalsTime,
                DTime = n.TackoffTime,
                Id = n.OrderId,
                Sequence = n.Sequence,
                TravelNo = n.FlightNo
            }).ToList();

            travelDataModels.AddRange(flightTravelDataModels);

            #endregion

            #region 机票改签行程

            List <FltModFlightEntity> modFlightList = (from modFlight in Context.Set <FltModFlightEntity>().AsNoTracking()
                                                       join modOrder in Context.Set <FltModOrderEntity>().AsNoTracking() on modFlight.Rmid equals modOrder.Rmid
                                                       join modPassenger in Context.Set <FltModPassengerEntity>().AsNoTracking() on modFlight.Rmid equals
                                                       modPassenger.Rmid
                                                       join passenger in Context.Set <FltPassengerEntity>().AsNoTracking() on modPassenger.Pid equals
                                                       passenger.PId
                                                       where
                                                       modFlight.TackoffTime.HasValue && modFlight.TackoffTime.Value > nowTime &&
                                                       (modOrder.ProcessStatus & 8) == 8 &&
                                                       passenger.Contactid == contactId
                                                       select modFlight).Distinct().ToList();

            List <FltModFlightModel> modFlightModels =
                Mapper.Map <List <FltModFlightEntity>, List <FltModFlightModel> >(modFlightList);
            modFlightModels.ForEach(n =>
            {
                SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode == n.Dport);
                if (airportModel != null)
                {
                    n.DportName = airportModel.AirportName;
                    SearchCityModel cityModel = cityModels.Find(x => x.CityCode == airportModel.CityCode);
                    n.DportCity = cityModel.CityName;
                }

                SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode == n.Aport);
                if (airportModel2 != null)
                {
                    n.AportName = airportModel2.AirportName;
                    SearchCityModel cityModel2 = cityModels.Find(x => x.CityCode == airportModel2.CityCode);
                    n.AportCity = cityModel2.CityName;
                }
            });

            List <TravelDataModel> modFlightTravelDataModels = (from n in modFlightModels
                                                                select new TravelDataModel()
            {
                Type = OrderSourceTypeEnum.FltMod.ToString(),
                AName = n.AportName,
                DName = n.DportName,
                ATime = n.ArrivalsTime.Value,
                DTime = n.TackoffTime.Value,
                Id = n.Orderid,
                Sequence = n.Sequence.Value,
                TravelNo = n.FlightNo
            }).ToList();

            travelDataModels.AddRange(modFlightTravelDataModels);

            #endregion

            #region 过滤正单和改签单


            //同一个订单,同一个行程Id,改签替换正单行程
            travelDataModels.ForEach(n =>
            {
                indexList.Add(n.Id + "|" + n.Sequence);
            });
            indexList = indexList.Distinct().ToList();


            foreach (string index in indexList)
            {
                int orderid  = Convert.ToInt32(index.Split('|')[0]);
                int sequence = Convert.ToInt32(index.Split('|')[1]);

                List <TravelDataModel> fightTempList =
                    travelDataModels.FindAll(
                        n => n.Id == orderid && n.Sequence == sequence && n.Type == OrderSourceTypeEnum.Flt.ToString());

                List <TravelDataModel> modFightTempList =
                    travelDataModels.FindAll(
                        n =>
                        n.Id == orderid && n.Sequence == sequence && n.Type == OrderSourceTypeEnum.FltMod.ToString());

                if (fightTempList != null && fightTempList.Count > 0 &&
                    (modFightTempList == null || modFightTempList.Count == 0))
                {
                    travel.DataList.AddRange(fightTempList);
                }
                else if (modFightTempList != null && modFightTempList.Count > 0)
                {
                    travel.DataList.AddRange(modFightTempList);
                }
            }

            #endregion

            #region 过滤退票订单

            List <int> refundId = new List <int>();
            if (travel.DataList != null && travel.DataList.Count > 0)
            {
                List <FltRefundOrderDetailEntity> fltRefundOrderDetailEntities =
                    base.Context.Set <FltRefundOrderDetailEntity>().Where(n => orderIdList.Contains(n.OrderId)).ToList();
                if (fltRefundOrderDetailEntities.Count > 0)
                {
                    for (int i = 0; i < travel.DataList.Count; i++)
                    {
                        FltRefundOrderDetailEntity fltRefundOrderEntity =
                            fltRefundOrderDetailEntities.Find(
                                n => n.OrderId == travel.DataList[i].Id && n.Sequence == travel.DataList[i].Sequence);
                        if (fltRefundOrderEntity != null)
                        {
                            refundId.Add(fltRefundOrderEntity.OrderId);
                        }
                    }
                }
            }

            #endregion

            if (refundId.Count > 0)
            {
                travel.DataList.RemoveAll(n => refundId.Contains(n.Id));
            }

            return(travel);
        }
Beispiel #10
0
        private TravelModel GetTrain(TravelQueryModel query)
        {
            if (!query.ContactId.HasValue)
            {
                throw new Exception("请传入ContactId参数");
            }

            TravelModel travel = new TravelModel();

            travel.DataList = new List <TravelDataModel>();

            int      contactId = query.ContactId.Value;
            DateTime nowTime   = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));

            List <int>             indexList        = new List <int>();
            List <TravelDataModel> travelDataModels = new List <TravelDataModel>();

            #region 火车正单行程

            List <TravelDataModel> trainTravelDataModels = (from detail in Context.Set <TraOrderDetailEntity>()
                                                            join order in Context.Set <TraOrderEntity>() on detail.OrderId equals order.OrderId
                                                            join status in Context.Set <TraOrderStatusEntity>() on detail.OrderId equals status.OrderId
                                                            join passenger in Context.Set <TraPassengerEntity>() on detail.OdId equals passenger.OdId
                                                            where passenger.ContactId.HasValue && passenger.ContactId == contactId &&
                                                            status.IsCancle == 0 && status.IsBuy == 1 && detail.StartTime > nowTime &&
                                                            !string.IsNullOrEmpty(detail.StartName) &&
                                                            !string.IsNullOrEmpty(detail.EndName) &&
                                                            detail.EndTime.HasValue
                                                            select new TravelDataModel()
            {
                Type = OrderSourceTypeEnum.Tra.ToString(),
                AName = detail.EndName,
                DName = detail.StartName,
                ATime = detail.EndTime.Value,
                DTime = detail.StartTime,
                Id = detail.OrderId,
                Sequence = 1,
                TravelNo = detail.TrainNo
            }).Distinct().ToList();
            travelDataModels.AddRange(trainTravelDataModels);

            #endregion

            #region 火车改签行程

            List <TravelDataModel> trainModTravelDataModels = (from modDetail in Context.Set <TraModOrderDetailEntity>()
                                                               join modOrder in Context.Set <TraModOrderEntity>() on modDetail.CorderId equals modOrder.CorderId
                                                               join passenger in Context.Set <TraPassengerEntity>() on modDetail.Pid equals passenger.Pid.ToString()
                                                               where passenger.ContactId.HasValue && passenger.ContactId == contactId &&
                                                               modDetail.SendTime.HasValue && modDetail.SendTime.Value > nowTime &&
                                                               !string.IsNullOrEmpty(modOrder.ProcessStatus) && modOrder.ProcessStatus.Contains("H") &&
                                                               !string.IsNullOrEmpty(modDetail.AddrName) &&
                                                               !string.IsNullOrEmpty(modDetail.EndName) &&
                                                               modDetail.EndTime.HasValue &&
                                                               modDetail.SendTime.HasValue
                                                               select new TravelDataModel()
            {
                Type = OrderSourceTypeEnum.TraMod.ToString(),
                AName = modDetail.EndName,
                DName = modDetail.AddrName,
                ATime = modDetail.EndTime.Value,
                DTime = modDetail.SendTime.Value,
                Id = modOrder.OrderId.Value,
                Sequence = 1,
                TravelNo = modDetail.TrainNo
            }).Distinct().ToList();

            travelDataModels.AddRange(trainModTravelDataModels);

            #endregion

            #region 过滤正单和改签单

            travelDataModels.ForEach(n =>
            {
                indexList.Add(n.Id);
            });

            foreach (int index in indexList)
            {
                List <TravelDataModel> traList =
                    travelDataModels.FindAll(
                        n => n.Id == index && n.Type == OrderSourceTypeEnum.Tra.ToString());

                List <TravelDataModel> modList =
                    travelDataModels.FindAll(
                        n =>
                        n.Id == index && n.Type == OrderSourceTypeEnum.TraMod.ToString());

                if (traList != null && traList.Count > 0 &&
                    (modList == null || modList.Count == 0))
                {
                    travel.DataList.AddRange(traList);
                }
                else if (modList != null && modList.Count > 0)
                {
                    travel.DataList.AddRange(modList);
                }
            }

            #endregion

            #region 过滤退票订单

            List <int> refundId = new List <int>();
            if (travel.DataList != null && travel.DataList.Count > 0)
            {
                List <TraOrderEntity> traOrderEntities =
                    base.Context.Set <TraOrderEntity>().Where(n => indexList.Contains(n.OrderRoot ?? 0)
                                                              &&
                                                              ((!n.IsModRefund.HasValue) || n.IsModRefund == false) &&
                                                              n.OrderType == 2)
                    .ToList();
                if (traOrderEntities.Count > 0)
                {
                    for (int i = 0; i < travel.DataList.Count; i++)
                    {
                        TraOrderEntity traOrderEntity =
                            traOrderEntities.Find(n => n.OrderRoot == travel.DataList[i].Id);
                        if (traOrderEntity != null)
                        {
                            refundId.Add(traOrderEntity.OrderRoot ?? 0); //有退票的订单号
                        }
                    }
                }
            }

            #endregion

            if (refundId.Count > 0)
            {
                travel.DataList.RemoveAll(n => refundId.Contains(n.Id));
            }

            return(travel);
        }
        public DataTable ConvertTravelIns(TravelModel _objMotorIns)
        {
            try
            {
                //sql string-string
                //sql long -long
                // sql int -int
                DataTable _dt = new DataTable();

                _dt.Columns.Add("IssueDate", typeof(DateTime));
                _dt.Columns.Add("PolicyNo", typeof(string));
                _dt.Columns.Add("Branch", typeof(string));
                _dt.Columns.Add("Planning", typeof(string));
                _dt.Columns.Add("NoOfDays", typeof(int));
                _dt.Columns.Add("CoverageType", typeof(string));
                _dt.Columns.Add("DepartureDate", typeof(DateTime));
                _dt.Columns.Add("DateOfReturn", typeof(DateTime));
                _dt.Columns.Add("DateOfBirth", typeof(DateTime));
                _dt.Columns.Add("TravelDestination", typeof(string));
                _dt.Columns.Add("PurposeOfVisit", typeof(string));
                _dt.Columns.Add("Marketer", typeof(string));
                _dt.Columns.Add("Broker_AgentCode", typeof(string));
                _dt.Columns.Add("IssueFrom", typeof(string));
                _dt.Columns.Add("AssuredName", typeof(string));
                _dt.Columns.Add("Gender", typeof(string));
                _dt.Columns.Add("CivilID", typeof(string));
                _dt.Columns.Add("Mobile", typeof(long));
                _dt.Columns.Add("PostBox", typeof(string));
                _dt.Columns.Add("PostalCode", typeof(string));
                _dt.Columns.Add("City", typeof(string));
                _dt.Columns.Add("Email", typeof(string));
                _dt.Columns.Add("LocalPersonName", typeof(string));
                _dt.Columns.Add("LocalPersonNo", typeof(string));
                _dt.Columns.Add("Nationality", typeof(string));
                _dt.Columns.Add("PassportNo", typeof(string));
                _dt.Columns.Add("Extension", typeof(string));
                _dt.Columns.Add("VipCustomer", typeof(string));
                _dt.Columns.Add("Remarks", typeof(string));
                _dt.Columns.Add("PolicyIsForOmanNationals_LegalResidentsOfOman", typeof(string));
                _dt.Columns.Add("SpecialDiscount", typeof(string));
                _dt.Columns.Add("AdditionalConditions", typeof(string));
                _dt.Columns.Add("MazayaCard", typeof(string));
                _dt.Columns.Add("AssuredNameFamilyMember", typeof(string));
                _dt.Columns.Add("DateOfBirthFamilyMember", typeof(DateTime));
                _dt.Columns.Add("Age", typeof(int));
                _dt.Columns.Add("Relationship", typeof(string));
                _dt.Columns.Add("Sex", typeof(string));
                _dt.Columns.Add("PassportNoFamilyMember", typeof(string));
                _dt.Columns.Add("ExtensionFamilyMember", typeof(string));
                ;

                DataRow _dr;
                _dr = _dt.NewRow();
                _dr["IssueDate"]         = _objMotorIns.IssueDate;
                _dr["PolicyNo"]          = _objMotorIns.PolicyNo;
                _dr["Branch"]            = _objMotorIns.Branch;
                _dr["Planning"]          = _objMotorIns.Planning;
                _dr["NoOfDays"]          = _objMotorIns.NoOfDays;
                _dr["CoverageType"]      = _objMotorIns.CoverageType;
                _dr["DepartureDate"]     = _objMotorIns.DepartureDate;
                _dr["DateOfReturn"]      = _objMotorIns.DateOfReturn;
                _dr["DateOfBirth"]       = _objMotorIns.DateOfBirth;
                _dr["TravelDestination"] = _objMotorIns.TravelDestination;
                _dr["PurposeOfVisit"]    = _objMotorIns.PurposeOfVisit;
                _dr["Marketer"]          = _objMotorIns.Marketer;
                _dr["Broker_AgentCode"]  = _objMotorIns.Broker_AgentCode;
                _dr["IssueFrom"]         = _objMotorIns.IssueFrom;
                _dr["AssuredName"]       = _objMotorIns.AssuredName;
                _dr["Gender"]            = _objMotorIns.Gender;
                _dr["CivilID"]           = _objMotorIns.CivilID;
                _dr["Mobile"]            = _objMotorIns.Mobile;
                _dr["PostBox"]           = _objMotorIns.PostBox;
                _dr["PostalCode"]        = _objMotorIns.PostalCode;
                _dr["City"]            = _objMotorIns.City;
                _dr["Email"]           = _objMotorIns.Email;
                _dr["LocalPersonName"] = _objMotorIns.LocalPersonName;
                _dr["LocalPersonNo"]   = _objMotorIns.LocalPersonNo;
                _dr["Nationality"]     = _objMotorIns.Nationality;
                _dr["PassportNo"]      = _objMotorIns.PassportNo;
                _dr["Extension"]       = _objMotorIns.Extension;
                _dr["VipCustomer"]     = _objMotorIns.VipCustomer;
                _dr["Remarks"]         = _objMotorIns.Remarks;
                _dr["PolicyIsForOmanNationals_LegalResidentsOfOman"] = _objMotorIns.PolicyIsForOmanNationals_LegalResidentsOfOman;
                _dr["SpecialDiscount"]         = _objMotorIns.SpecialDiscount;
                _dr["AdditionalConditions"]    = _objMotorIns.AdditionalConditions;
                _dr["MazayaCard"]              = _objMotorIns.MazayaCard;
                _dr["AssuredNameFamilyMember"] = _objMotorIns.AssuredNameFamilyMember;
                _dr["DateOfBirthFamilyMember"] = _objMotorIns.DateOfBirthFamilyMember;
                _dr["Age"]                    = _objMotorIns.Age;
                _dr["Relationship"]           = _objMotorIns.Relationship;
                _dr["Sex"]                    = _objMotorIns.Sex;
                _dr["PassportNoFamilyMember"] = _objMotorIns.PassportNoFamilyMember;
                _dr["ExtensionFamilyMember"]  = _objMotorIns.ExtensionFamilyMember;
                _dt.Rows.Add(_dr);

                return(_dt);
            }
            catch (Exception ex)
            {
                throw;
            }
        }