public void OpenTravelDetails(Guid travelId)
        {
            var unitOfWork       = UnitOfWorkFactory.CreateUnitOfWork();
            var travelRepository = RepositoriesFactory.CreateTravelRepository(unitOfWork);

            try
            {
                unitOfWork.BeginTransaction();

                var travel = travelRepository.GetTravel(travelId);

                var travelModal = new TravelViewModel
                {
                    Id          = travel.Id,
                    Name        = travel.Name,
                    Description = travel.Description,
                    DateStart   = travel.DateStart,
                    DateEnd     = travel.DateEnd,
                    Budget      = travel.Budget
                };

                unitOfWork.Commit();

                var travelDetailsView = _formsFactory.CreateTravelDetailsView(this, travelModal);
                travelDetailsView.ShowModaless();
            }
            catch (Exception ex)
            {
                unitOfWork.Rollback();

                MessageBox.Show(ex.Message, "TravelBuddy");
            }
        }
示例#2
0
 private void FormTravel_Load(object sender, EventArgs e)
 {
     if (id.HasValue)
     {
         try
         {
             TravelViewModel view = logic.Read(new TravelBindingModel {
                 Id = id.Value
             })?[0];
             if (view != null)
             {
                 textBoxName.Text  = view.TravelName;
                 textBoxPrice.Text = view.FinalCost.ToString();
                 TravelTours       = view.TravelTours;
                 LoadData();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
     }
     else
     {
         TravelTours = new List <TravelTourViewModel>();
     }
 }
示例#3
0
        public TravelDetails(ITravelController travelController, TravelViewModel travelModel)
        {
            _travelController = travelController;
            _travelModel      = travelModel;

            InitializeComponent();
        }
示例#4
0
        public NewTravelPage()
        {
            InitializeComponent();

            post            = new Post();
            travelViewModel = new TravelViewModel();
            BindingContext  = travelViewModel;
        }
示例#5
0
        public ActionResult Index()
        {
            TravelViewModel viewModel = new TravelViewModel()
            {
                MRT2Stations = GetMRT2List()
            };

            return(View(viewModel));
        }
示例#6
0
        private Tracking TravelTracking(TravelViewModel model)
        {
            var tracking = _context.Tracking.Find(model.TrackingId);

            tracking.Transportation = model.TranspoId.ToString();
            tracking.UpdatedAt      = DateTime.Now;

            return(tracking);
        }
示例#7
0
        public TravelWindow(TravelList travelList)
        {
            InitializeComponent();
            TravelViewModel vm = new TravelViewModel(travelList);

            DataContext = vm;
            if (vm.CloseAction == null)
            {
                vm.CloseAction = new Action(this.Close);
            }
        }
示例#8
0
        public async Task <IActionResult> Create(TravelViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateAsync(_mapper.Map <TravelDTO>(vm));

                return(result.IsValid
                    ? RedirectToAction("Index")
                    : _oops.OutPutError("Travel", "Index", result.ErrorsList));
            }
            return(View(vm));
        }
        // GET: Travels
        public ActionResult Index(TravelViewModel model)
        {
            IEnumerable <Travel> liste = db.Travels.Include(x => x.Destination).Include(x => x.TravelAgency);

            if (model.DepartureDateMax != null)
            {
                liste = liste.Where(x => x.DepartureDate <= model.DepartureDateMax);
            }

            if (model.DepartureDateMin != null)
            {
                liste = liste.Where(x => x.DepartureDate >= model.DepartureDateMin);
            }

            if (model.ReturnDateMax != null)
            {
                liste = liste.Where(x => x.ReturnDate <= model.ReturnDateMax);
            }

            if (model.ReturnDateMin != null)
            {
                liste = liste.Where(x => x.ReturnDate >= model.ReturnDateMin);
            }

            if (model.AllInclusivePriceMax != null)
            {
                liste = liste.Where(x => x.AllInclusivePrice <= model.AllInclusivePriceMax);
            }

            if (model.AllInclusivePriceMin != null)
            {
                liste = liste.Where(x => x.AllInclusivePrice >= model.AllInclusivePriceMin);
            }

            if (!string.IsNullOrWhiteSpace(model.Continent))
            {
                liste = db.Travels.Include(x => x.Destination).Include(x => x.TravelAgency).Where(x => x.Destination.Continent.Contains(model.Continent));
            }

            if (!string.IsNullOrWhiteSpace(model.Country))
            {
                liste = db.Travels.Include(x => x.Destination).Include(x => x.TravelAgency).Where(x => x.Destination.Country.Contains(model.Country));
            }

            if (!string.IsNullOrWhiteSpace(model.Region))
            {
                liste = db.Travels.Include(x => x.Destination).Include(x => x.TravelAgency).Where(x => x.Destination.Region.Contains(model.Region));
            }

            model.Travels = liste.ToList();
            return(View(model));
        }
示例#10
0
        public async Task <ActionResult <TravelViewModel> > Adicionar(TravelViewModel travelViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            Convert.ToDateTime(travelViewModel.DataViagem);
            travelViewModel.TravelId = Guid.NewGuid();
            await _travelService.Adicionar(_mapper.Map <Travel>(travelViewModel));

            return(CustomResponse(travelViewModel));
        }
示例#11
0
        public async Task <IActionResult> Travel([Bind] TravelViewModel model)
        {
            if (ModelState.IsValid)
            {
                var tracking = TravelTracking(model);
                var activity = TravelActivity(tracking);
                _context.Update(tracking);
                _context.Add(activity);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Referred", "ViewPatients"));
            }
            return(PartialView());
        }
示例#12
0
        // GET: Travel
        public ActionResult Index()
        {
            TravelViewModel TravelViewModelData = new TravelViewModel()
            {
                Attractionslist    = AttractionsData.GetAll(),
                AttractionsImglist = AttractionsImgData.GetAll()
            };

            if (TravelViewModelData == null)
            {
                return(HttpNotFound());
            }
            return(View(TravelViewModelData));
        }
示例#13
0
        public async Task <IActionResult> UpdateConfirmed(TravelViewModel vm)
        {
            if (ModelState.IsValid)
            {
                if (vm.HashId == null)
                {
                    return(NotFound());
                }
                var result = await _services.UpdateAsync(_mapper.Map <TravelDTO>(vm));

                return(result.IsValid
                    ? RedirectToAction("Index")
                    : _oops.OutPutError("Travel", "Index", result.ErrorsList));
            }
            return(View(vm));
        }
示例#14
0
        public async Task <ActionResult> Create(TravelViewModel travel)
        {
            if (ModelState.IsValid)
            {
                await _mediator.Send(new CreateTravelCommand
                {
                    Name        = travel.Name,
                    Description = travel.Description,
                    Email       = email,
                    UserId      = userId
                });

                return(RedirectToAction(nameof(Index)));
            }

            return(View(travel));
        }
示例#15
0
        public async Task <ActionResult> Update(int id, TravelViewModel travel)
        {
            if (ModelState.IsValid)
            {
                await _mediator.Send(new UpdateTravelDescriptionCommand
                {
                    Id          = id,
                    IsAdmin     = isAdmin,
                    Email       = email,
                    Description = travel.Description,
                    UserId      = userId
                });

                return(RedirectToAction(nameof(Index)));
            }

            return(View(travel));
        }
示例#16
0
        public async Task <IActionResult> Atualizar(Guid id, TravelViewModel travelViewModel)
        {
            if (id != travelViewModel.Id)
            {
                NotificarErro("Os ids informados não são iguais!");
                return(CustomResponse());
            }

            var viagemAtualizacao = await _travelRepository.ObterViagemPorId(id);

            viagemAtualizacao.Nome       = travelViewModel.Nome;
            viagemAtualizacao.Origem     = travelViewModel.Origem;
            viagemAtualizacao.Destino    = travelViewModel.Destino;
            viagemAtualizacao.DataViagem = Convert.ToDateTime(travelViewModel.DataViagem);


            await _travelService.Atualizar(_mapper.Map <Travel>(viagemAtualizacao));

            return(CustomResponse(travelViewModel));
        }
示例#17
0
        public ActionResult Index(Attractions Data)
        {
            if (Data == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (Data.CityName != null && Data.CityName.Trim().Substring(0, 1) == "台")
            {
                Data.CityName = Data.CityName.Replace('台', '臺');
            }


            TravelViewModel TravelViewModelData = new TravelViewModel()
            {
                Attractionslist    = AttractionsData.GetDataforCityName(Data),
                AttractionsImglist = AttractionsImgData.GetDataforCityName(Data)
            };

            if (TravelViewModelData == null)
            {
                return(HttpNotFound());
            }
            return(View(TravelViewModelData));
        }
示例#18
0
        // GET: Home
        public ActionResult Index()
        {
            PostViewModel postViewModel = new PostViewModel();
            var           homePost      = postManager.GetAll().OrderByDescending(c => c.Id);


            var politicsPost = homePost.Where(c => c.Category.Name == "Politics");

            var             datas           = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Politics");
            BannerViewModel bannerViewModel = new BannerViewModel()
            {
                Id          = datas.Id,
                Title       = datas.Title,
                Description = datas.Description,
                ImagePath   = datas.ImagePath,
                Tags        = datas.Tags,
                PostDate    = datas.PostDate
            };

            List <SiteBannerViewModel> siteBannerViewModels = new List <SiteBannerViewModel>();
            var siteBannder = homePost.Where(c => c.Category.Name == "Politics").OrderByDescending(c => c.Id).Skip(1).Take(2);

            foreach (var data in siteBannder)
            {
                var siteBannerVM = new SiteBannerViewModel()
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    Description = data.Description,
                    ImagePath   = data.ImagePath
                };
                siteBannerViewModels.Add(siteBannerVM);
            }

            /*banner Bottom post*/
            List <BannerBottomViewModel> bannerBottomViewModels = new List <BannerBottomViewModel>();
            var BannerBottom = homePost.Where(c => c.Category.Name == "Politics").OrderByDescending(c => c.Id).Skip(3).Take(4);

            foreach (var data in BannerBottom)
            {
                var bannerBottomVM = new BannerBottomViewModel()
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    Description = data.Description,
                    ImagePath   = data.ImagePath,
                    PostDate    = data.PostDate.ToString("d")
                };
                bannerBottomViewModels.Add(bannerBottomVM);
            }
            postViewModel.BannerBottomViewModels = bannerBottomViewModels;
            /*banner Bottom post*/

            /*latest Post */
            List <LatestPostViewModel> latestPostViewModels = new List <LatestPostViewModel>();
            var latestPost = homePost.Where(c => c.Category.Name == "Politics").OrderByDescending(c => c.Id).Skip(7).Take(7);

            foreach (var data in latestPost)
            {
                var latestPostVM = new LatestPostViewModel()
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    Description = data.Description,
                    ImagePath   = data.ImagePath
                };
                latestPostViewModels.Add(latestPostVM);
            }
            postViewModel.LatestPostViewModels = latestPostViewModels;
            /*latest Post */

            /*popular Post */
            var popularPost = homePost.Skip(14).Take(4);
            List <PopularPostViewModel> popularPostViewModels = new List <PopularPostViewModel>();

            foreach (var data in popularPost)
            {
                var popularPostVM = new PopularPostViewModel()
                {
                    Id        = data.Id,
                    Title     = data.Title,
                    PostDate  = data.PostDate.ToString("d"),
                    ImagePath = data.ImagePath,
                    Category  = data.Category
                };
                popularPostViewModels.Add(popularPostVM);
            }
            postViewModel.PopularPostViewModels = popularPostViewModels;
            /*popular Post */

            /*Sports Post */
            var entertainmentPost = homePost.Where(c => c.Category.Name == "Entertainment").OrderByDescending(c => c.Id).Take(4);
            List <EntertainmentViewModel> entertainmentViewModels = new List <EntertainmentViewModel>();

            foreach (var data in entertainmentPost)
            {
                var entertainmentVM = new EntertainmentViewModel()
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    ImagePath   = data.ImagePath,
                    Description = data.Description,
                    PostDate    = data.PostDate.ToString("D")
                };
                entertainmentViewModels.Add(entertainmentVM);
            }
            postViewModel.EntertainmentViewModels = entertainmentViewModels;
            /*Sports Post */



            /*Sports Post */
            var sportsPost = homePost.Where(c => c.Category.Name == "Sports").OrderByDescending(c => c.Id).Take(4);
            List <SportsViewModel> sportsViewModels = new List <SportsViewModel>();

            foreach (var data in sportsPost)
            {
                var sportsVM = new SportsViewModel()
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    ImagePath   = data.ImagePath,
                    Description = data.Description,
                    PostDate    = data.PostDate.ToString("D")
                };
                sportsViewModels.Add(sportsVM);
            }
            postViewModel.SportsViewModels = sportsViewModels;
            /*Sports Post */


            /*technology Post */
            var techPost = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Technology");
            TechnologyViewModel technologyViewModel = new TechnologyViewModel()
            {
                Id          = techPost.Id,
                Title       = techPost.Title,
                Description = techPost.Description,
                PostDate    = techPost.PostDate.ToString("D"),
                ImagePath   = techPost.ImagePath
            };

            postViewModel.TechnologyViewModel = technologyViewModel;
            /*technology Post */

            /*education Post */
            var educationPost = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Education");
            EducationViewModel educationViewModel = new EducationViewModel()
            {
                Id          = educationPost.Id,
                Title       = educationPost.Title,
                Description = educationPost.Description,
                ImagePath   = educationPost.ImagePath,
                PostDate    = educationPost.PostDate.ToString("D")
            };

            postViewModel.EducationViewModel = educationViewModel;
            /*education Post */

            /*travel Post */
            var             travelPost      = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Travel");
            TravelViewModel travelViewModel = new TravelViewModel()
            {
                Id          = travelPost.Id,
                Title       = travelPost.Title,
                Description = travelPost.Description,
                ImagePath   = travelPost.ImagePath,
                PostDate    = travelPost.PostDate.ToString("D")
            };

            postViewModel.TravelViewModel = travelViewModel;
            /*travel Post */


            /*food Post */
            var           foodPost      = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Food");
            FoodViewModel foodViewModel = new FoodViewModel()
            {
                Id          = foodPost.Id,
                Title       = foodPost.Title,
                Description = foodPost.Description,
                ImagePath   = foodPost.ImagePath,
                PostDate    = foodPost.PostDate.ToString("D")
            };

            postViewModel.FoodViewModel = foodViewModel;
            /*food Post */

            /*health Post */
            var             healthPost      = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Health");
            HealthViewModel healthViewModel = new HealthViewModel()
            {
                Id          = healthPost.Id,
                Title       = healthPost.Title,
                Description = healthPost.Description,
                ImagePath   = healthPost.ImagePath,
                PostDate    = healthPost.PostDate.ToString("D")
            };

            postViewModel.HealthViewModel = healthViewModel;
            /*health Post */


            /*economics Post */
            var economicsPost = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Economics");
            EconomicsViewModel economicsViewModel = new EconomicsViewModel()
            {
                Id          = economicsPost.Id,
                Title       = economicsPost.Title,
                Description = economicsPost.Description,
                ImagePath   = economicsPost.ImagePath,
                PostDate    = economicsPost.PostDate.ToString("D")
            };

            postViewModel.EconomicsViewModel = economicsViewModel;
            /*economics Post */

            postViewModel.BannerViewModel      = bannerViewModel;
            postViewModel.SiteBannerViewModels = siteBannerViewModels;

            return(View(postViewModel));
        }
示例#19
0
        // GET: Travel/Create
        public ActionResult Create()
        {
            var model = new TravelViewModel();

            return(View(model));
        }
 public ITravelDetailsView CreateTravelDetailsView(ITravelController travelController,
                                                   TravelViewModel travelModel)
 {
     return(new TravelDetails(travelController, travelModel));
 }