Beispiel #1
0
        public async Task <IActionResult> CreateTour(TourDTO tourDto)
        {
            var tour = _mapper.Map <TourDTO, Tour>(tourDto);
            await _repository.Add(tour);

            return(CreatedAtAction(nameof(GetTour), new { id = tour.TourId }, tour));
        }
Beispiel #2
0
        //consider changing the out parameter to a validation type object
        public void Save(ITour tour, out bool success)
        {
            Checks.Argument.IsNotNull(tour, "tour");

            success = false;

            if (null == _repo.FindByTourId(tour.TourId))
            {
                try
                {
                    _repo.Add(tour);
                    success = true;
                }
                catch (Exception ex)
                {
                    success = false;
                }
            }
        }
        async Task IStartDataService.AddTour()
        {
            Tour tour = new Tour();

            tour.FoodType = await _foodTypeRepository.Get(1);

            tour.TransportType = await _transportTypeRepository.Get(1);

            tour.TourType = await _tourTypeRepository.Get(1);

            tour.CityFrom = await _cityFromRepository.Get(1);

            tour.Hotel = await _hotelRepository.Get(1);

            tour.CountOfTours = 3;
            tour.DateFrom     = new DateTime(2018, 5, 5);
            tour.DateTo       = new DateTime(2018, 5, 15);
            tour.Price        = 400;
            await _tourRepository.Add(tour);
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!check())
            {
                MessageBox.Show("Thông tin thiếu hoặc không hợp lệ !");
            }
            else
            {
                Tour newtour = new Tour();
                newtour.CTTours = new List <CTTour>();
                newtour.Gias    = new List <Gia>();
                Gia newgia = new Gia();
                newtour.MaTour = matourtb.Text;
                newtour.Ten    = tentourtb.Text;

                LoaiHinhDL item = new LoaiHinhDL();
                item         = (LoaiHinhDL)loaihinhcbb.SelectedItem;
                newtour.LHDL = item;

                foreach (ListViewItem dd in diadiem.CheckedItems)
                {
                    CTTour newcttour = new CTTour();
                    newcttour.DDId   = Convert.ToInt32(dd.SubItems[0].Text);
                    newcttour.TourId = newtour.TourId;
                    //_cTTourRepository.Add(newcttour);
                    newtour.CTTours.Add(newcttour);
                }
                newgia.GiaTri = (int)mucgia.Value;
                newgia.TGBD   = tungay.Value;
                newgia.TGKT   = denngay.Value;
                newgia.TourId = newtour.TourId;
                newtour.Gias.Add(newgia);
                _tourRepository.Add(newtour);
                // _giaRepository.Add(newgia);
                MessageBox.Show("Thêm thành công!");
                Program.Form.TabRefresh(ListTab.Tour);
            }
        }
        public ActionResult Create(Tour tour, List <string> DestinationIds, List <HttpPostedFileBase> filesInput)
        {
            if (ModelState.IsValid)
            {
                if (filesInput != null)
                {
                    try
                    {
                        foreach (var item in filesInput)
                        {
                            string fileName = "";
                            fileName = Path.GetFileName(item.FileName);
                            string path = Path.Combine(Server.MapPath("~/Content/images/tours"), fileName);
                            item.SaveAs(path);
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                _tourRepository.Add(tour);
                foreach (var item in DestinationIds)
                {
                    var tourdestination = new TourDestination();
                    tourdestination.IdTour        = tour.Id;
                    tourdestination.IdDestination = Int32.Parse(item);

                    _tourDestinationRepository.Add(tourdestination);
                }
                return(Content($"<script language='javascript' type='text/javascript'> alert('Thêm thành công'); window.location.href='https://localhost:44316/Admin/ToursManagement?page=1' </script>"));
            }

            ViewBag.CategoryId    = new SelectList(db.Categories, "Id", "Name", tour.CategoryId);
            ViewBag.DestiantionId = new SelectList(_destinatioRepository.GetAll().OrderBy(x => x.Name), "Id", "Name");
            ViewBag.EmployeeId    = new SelectList(_employeeRepository.GetAll(), "Id", "Name");
            return(View(tour));
        }
Beispiel #6
0
        public async Task AddTour(Tour tour)
        {
            await _repository.Add(tour);

            await _unit.Complete();
        }
Beispiel #7
0
        async Task <TourDTO> IService <TourDTO, int> .Add(TourDTO entity)
        {
            Tour tour = await _tourRepository.Add(_mapper.Map <TourDTO, Tour>(entity));

            return(_mapper.Map <Tour, TourDTO>(tour));
        }
Beispiel #8
0
 public bool Add(TourView model)
 {
     return(_tour.Add(model));
 }
Beispiel #9
0
 public void AddTour(Tour tour)
 {
     tourRepository.Add(tour);
 }