Ejemplo n.º 1
0
        public async Task <ActionResult <Tourist> > PostTourist(Tourist tourist)
        {
            var isTouristExist = await _context.Tourist.AnyAsync(x => x.Email == tourist.Email);

            if (isTouristExist)
            {
                return(StatusCode(StatusCodes.Status409Conflict, $"Tourist with email address {tourist.Email} is already exists."));
            }

            _context.Tourist.Add(tourist);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTourist", new { id = tourist.Id }, tourist));
        }
Ejemplo n.º 2
0
        // GET: Tourists/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tourist tourist = db.Tourists.Find(id);

            if (tourist == null)
            {
                return(HttpNotFound());
            }
            return(View(tourist));
        }
Ejemplo n.º 3
0
        internal void SetPlan(Location location, Tourist tourist, Guide guide, DateTime datetime)
        {
            Plan p = db.Plans.Where(a => a.ArrivalDateInTurkey == datetime && a.Guide.Name == guide.Name && a.Guide.Surname == guide.Surname && a.Tourist.Name == tourist.Name && a.Tourist.Surname == tourist.Surname && a.Location.LocationDescription == location.LocationDescription).FirstOrDefault();

            if (p == null)
            {
                p                     = new Plan();
                p.GuideID             = db.Guides.Where(a => a.Name == guide.Name && a.Surname == guide.Surname).Select(a => a.GuideID).FirstOrDefault();
                p.LocationID          = db.Locations.Where(a => a.LocationDescription == location.LocationDescription).Select(a => a.LocationID).FirstOrDefault();
                p.TouristID           = db.Tourists.Where(a => a.Name == tourist.Name && a.Surname == tourist.Surname && a.BirthDate == tourist.BirthDate).Select(a => a.TouristID).FirstOrDefault();
                p.ArrivalDateInTurkey = datetime;
                db.Plans.Add(p);
                db.SaveChanges();
            }
        }
Ejemplo n.º 4
0
 public ActionResult Delete(int ID, Tourist tourist)
 {
     try
     {
         // TODO: Add delete logic here
         tourist = db.Tourists.Where(c => c.ID == ID).FirstOrDefault();
         db.Tourists.Remove(tourist);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(ID));
     }
 }
Ejemplo n.º 5
0
        public ActionResult Create(Tourist tourist)
        {
            try
            {
                db.Tourists.Add(tourist);
                db.SaveChanges();
                // TODO: Add insert logic here

                return(RedirectToAction("Index", "tourist"));
            }
            catch
            {
                return(View(tourist));
            }
        }
Ejemplo n.º 6
0
 public string Loging([FromBody] Tourist user)
 {
     using (thanujaEntities db = new thanujaEntities())
     {
         var login = db.Tourists.Where(u => u.UserName == user.UserName).FirstOrDefault();
         if (login.Password == user.Password)
         {
             return("loging success");
         }
         else
         {
             return("LOGING FAILED");
         }
     }
 }
Ejemplo n.º 7
0
        // GET: Tourists/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tourist tourist = db.Tourists.Find(id);

            if (tourist == null)
            {
                return(HttpNotFound());
            }


            var Results = from f in db.Flights
                          select new
            {
                f.FlightId,
                f.Name,
                Checked = ((from tf in db.TouristsToFlights
                            where (tf.TouristId == id) & (tf.FlightId == f.FlightId)
                            select tf).Count() > 0)
            };
            var MyViewModel = new TouristsViewModel();

            MyViewModel.TouristId   = id.Value;
            MyViewModel.FirstName   = tourist.FirstName;
            MyViewModel.LastName    = tourist.LastName;
            MyViewModel.Gender      = tourist.Gender;
            MyViewModel.Country     = tourist.Country;
            MyViewModel.Remarks     = tourist.Remarks;
            MyViewModel.DateOfBirth = tourist.DateOfBirth;

            var MyCheckBoxList = new List <CheckBoxViewModel>();

            foreach (var item in Results)
            {
                MyCheckBoxList.Add(new CheckBoxViewModel
                {
                    Id      = item.FlightId,
                    Name    = item.Name,
                    Checked = item.Checked
                });
            }

            MyViewModel.Flights = MyCheckBoxList;
            return(View(MyViewModel));
        }
Ejemplo n.º 8
0
        public void TestGetByIdBookingsOK()
        {
            Tourist tourist = new Tourist
            {
                Email    = "*****@*****.**",
                Id       = 1,
                Name     = "s",
                LastName = "b"
            };
            Accommodation accommodation = new Accommodation
            {
                Id            = 5,
                Name          = "a",
                Address       = "a",
                ContactNumber = "2"
            };
            Booking booking = new Booking
            {
                Id            = 5,
                TotalPrice    = 10,
                CheckIn       = DateTime.Now.AddDays(1),
                CheckOut      = DateTime.Now.AddDays(2),
                HeadGuest     = tourist,
                Accommodation = accommodation
            };
            Guest guest = new Guest
            {
                Amount     = 1,
                Multiplier = 1
            };
            List <Guest> guestList = new List <Guest>
            {
                guest,
                guest,
                guest
            };

            booking.Guests = guestList;
            var mockBooking = new Mock <IBookingLogic>(MockBehavior.Strict);

            mockBooking.Setup(p => p.GetById(It.IsAny <int>())).Returns(booking);
            var controller = new BookingController(mockBooking.Object);

            var result = controller.Get(5) as OkObjectResult;

            mockBooking.VerifyAll();
            Assert.AreEqual(200, result.StatusCode);
        }
Ejemplo n.º 9
0
        public void TestInitialize()
        {
            var lodging = new Lodging()
            {
                Id          = 1,
                Name        = "Name",
                Description = "Description",
                Rating      = 3,
                IsFull      = true,
                Images      = new List <LodgingImage>()
                {
                    new LodgingImage()
                },
                PricePerNight       = 100,
                Address             = "Valid Address 123",
                Phone               = "+598 98 303 040",
                ConfirmationMessage = "Your reservation has been confirmed!",
                TouristSpot         = null
            };

            var tourist = new Tourist()
            {
                Name     = "aName",
                LastName = "aLastName",
                Email    = "*****@*****.**"
            };

            var booking = new Booking()
            {
                Id       = 1,
                CheckIn  = DateTime.Now,
                CheckOut = DateTime.Now.AddDays(5),
                Lodging  = lodging,
                Guests   = 3,
                Tourist  = tourist,
            };

            BookingState = new BookingState
            {
                Id          = 1,
                Booking     = booking,
                BookingId   = booking.Id,
                State       = "Aceptada",
                Description = "Primer estado"
            };

            BookingStateBasicInfoModel = new BookingStateBasicInfoModel(BookingState);
        }
Ejemplo n.º 10
0
        public ActionResult <Tourist> Create([FromBody] Tourist tourist)
        {
            if (string.IsNullOrWhiteSpace(tourist.Fio))
            {
                ModelState.AddModelError("Name", "Tour name must be non empty string");
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newTourist = repository.Create(tourist);

            return(Ok(newTourist));
        }
Ejemplo n.º 11
0
        public bool CheckEmailExist(string TouristEmail)
        {
            bool    result;
            Tourist tour = new Tourist();

            tour = (from c in entity.Tourists where c.TouristEmail == TouristEmail select c).SingleOrDefault();
            if (tour != null)
            {
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
 public JsonResult Insert(Tourist tourist)
 {
     if (tourist != null)
     {
         using (ApplicationDbContext db = new ApplicationDbContext())
         {
             db.Tourists.Add(tourist);
             db.SaveChanges();
             return(Json(new { success = true }));
         }
     }
     else
     {
         return(Json(new { success = false }));
     }
 }
Ejemplo n.º 13
0
        public void SetTourist(Tourist tourist, Nationality nationality, Gender gender)
        {
            Tourist t = db.Tourists.Where(a => a.Name == tourist.Name & a.Surname == tourist.Surname & a.BirthDate == tourist.BirthDate & a.Nationality.NationalityDescription == nationality.NationalityDescription & a.Gender.GenderDescription == gender.GenderDescription).FirstOrDefault();

            if (t == null)
            {
                t               = new Tourist();
                t.Name          = tourist.Name;
                t.Surname       = tourist.Surname;
                t.BirthDate     = tourist.BirthDate;
                t.NationalityID = db.Nationalities.Where(a => a.NationalityDescription == nationality.NationalityDescription).Select(a => a.NationalityID).FirstOrDefault();
                t.GenderID      = db.Genders.Where(a => a.GenderDescription == gender.GenderDescription).Select(a => a.GenderID).FirstOrDefault();
                db.Tourists.Add(t);
                db.SaveChanges();
            }
        }
Ejemplo n.º 14
0
        public void TestAddTourist()
        {
            Tourist tourist = new Tourist()
            {
                Id       = 3,
                Name     = "Pepe",
                LastName = "Lopez",
                Email    = "*****@*****.**",
                Bookings = null,
            };
            var repository = new TouristRepository(_context);

            repository.AddAndSave(tourist);

            Assert.AreEqual(_context.Find <Tourist>(3), tourist);
        }
        public void TestAddBooking()
        {
            List <AccommodationImage> list  = new List <AccommodationImage>();
            AccommodationImage        image = new AccommodationImage()
            {
                AccommodationId = 1,
                Image           = "a"
            };

            list.Add(image);
            Accommodation accommodation = new Accommodation()
            {
                Id            = 1,
                Name          = "a",
                Address       = "d",
                ContactNumber = "a",
                Images        = list
            };

            this._context.Accommodations.Add(accommodation);
            Booking booking = new Booking()
            {
                Id              = 1,
                Accommodation   = null,
                AccommodationId = 1,
                BookingHistory  = null,
                CheckIn         = DateTime.Now,
                CheckOut        = DateTime.Now.AddDays(7),
                GuestId         = 6,
                Guests          = new List <Guest>(),
                HeadGuest       = null,
                TotalPrice      = 142
            };
            Tourist tourist = new Tourist()
            {
                Email    = "*****@*****.**",
                LastName = "a",
                Name     = "a"
            };

            booking.HeadGuest = tourist;
            var repository = new BookingRepository(_context);

            repository.AddAndSave(booking);

            Assert.AreEqual(_context.Find <Booking>(1), booking);
        }
Ejemplo n.º 16
0
        public void DeactivateAllExpiredHost()
        {
            var host = (from c in entity.Hosts where c.HostingStopTime < DateTime.Now && c.HostingStatus == true select c).ToList();

            foreach (var item in host)
            {
                item.HostingStatus = false;
                bool result = (from c in entity.Hosts where c.TouristId == item.TouristId && c.HostingStopTime >= DateTime.Now select c).Any();
                if (result == false)
                {
                    Tourist tourist =
                        (from c in entity.Tourists where c.TouristId == item.TouristId select c).FirstOrDefault();
                    tourist.TouristsHostStatus = false;
                }
            }
            entity.SaveChanges();
        }
Ejemplo n.º 17
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (System.Web.HttpContext.Current.Session["CurrentUser"] is ConnectedWorker)
            {
                if ((System.Web.HttpContext.Current.Session["CurrentUser"] as ConnectedWorker).Power == 2 ||
                    (System.Web.HttpContext.Current.Session["CurrentUser"] as ConnectedWorker).Power == 1)
                {
                    try
                    {
                        Tourist tourist = db.Tourists.Find(id);

                        List <Tourist> livingInCurrentRoom = db.Tourists.AsNoTracking().Where(c => c.RoomId == tourist.RoomId).Select(c => c).ToList();

                        if (livingInCurrentRoom.Count - 1 == 0)
                        {
                            Room room = db.Rooms.Find(tourist.RoomId);
                            room.IsAvailable     = true;
                            db.Entry(room).State = EntityState.Modified;
                            db.SaveChanges();
                        }

                        if (tourist == null)
                        {
                            return(HttpNotFound());
                        }

                        db.Tourists.Remove(tourist);
                        db.SaveChanges();

                        return(RedirectToAction("Index"));
                    }
                    catch
                    {
                        return(View());
                    }
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            else
            {
                return(HttpNotFound());
            }
        }
Ejemplo n.º 18
0
        internal static void CheckClientDefault()
        {
            var Turistdb   = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
            var userTurist = Turistdb.FindByName("*****@*****.**");

            if (userTurist == null)
            {
                CreateUserASP("*****@*****.**", "Turista123", "Tourist");
                userTurist = Turistdb.FindByName("*****@*****.**");
                var Tourist = new Tourist
                {
                    UserId = userTurist.Id,
                };
                db.Tourists.Add(Tourist);
                db.SaveChanges();
            }
        }
Ejemplo n.º 19
0
        public void DeactivateHost(int HostId)
        {
            Host host      = (from c in entity.Hosts where c.HostId == HostId select c).FirstOrDefault();
            int  touristId = Convert.ToInt32(host.TouristId);

            host.HostingStatus = false;
            entity.SaveChanges();
            bool Result = (from c in entity.Hosts where c.TouristId == touristId && c.HostingStatus == true select c).Any();

            if (Result == false)
            {
                Tourist tourist =
                    (from c in entity.Tourists where c.TouristId == touristId select c).FirstOrDefault();
                tourist.TouristsHostStatus = false;
                entity.SaveChanges();
            }
        }
Ejemplo n.º 20
0
        //Adds new tourist in the database
        public string RegisterTourist(string touristFirstName, string touristLastName, int age, string countryName)
        {
            Tourist tourist = new Tourist()
            {
                TouristFirstName = touristFirstName,
                TouristLastName  = touristLastName,
                Age         = age,
                CountryName = countryName
            };

            context.Tourists.Add(tourist);
            context.SaveChanges();

            string result = "Tourist successfully registered.";

            return(result);
        }
Ejemplo n.º 21
0
        public void Delete(TouristBindingModel model)
        {
            using (var context = new TourFirmDatabase())
            {
                Tourist element = context.Tourists.FirstOrDefault(rec => rec.ID == model.ID);

                if (element != null)
                {
                    context.Tourists.Remove(element);
                    context.SaveChanges();
                }
                else
                {
                    throw new Exception("Элемент не найден");
                }
            }
        }
Ejemplo n.º 22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Tour_Guide tg = new Tour_Guide(Session["username"].ToString());

        tg.setInfo();

        TID.Text = Session["tourID"].ToString();
        String tourID = Session["tourID"].ToString();

        Booking b      = new Booking();
        Tourist t      = new Tourist();
        String  reader = b.getBookingTuples(tourID);

        String[] readerArr = reader.Split(';'); // contains array of tourist IDs
        // for each tourist ID, query the tourist database and return name and country
        Array.Resize(ref readerArr, readerArr.Length - 1);

        for (int i = 0; i < readerArr.Length; i++)
        {
            String   touristID      = readerArr[i].ToString();
            String   touristInfo    = t.queryTourist(touristID);
            String[] touristInfoArr = touristInfo.Split(';');
            Array.Resize(ref touristInfoArr, touristInfoArr.Length - 1);

            LinkButton s = new LinkButton();
            s.Text   = touristInfoArr[0].ToString();
            s.Click += new EventHandler(goToTourist);

            TableRow  detailsRow = new TableRow();
            TableCell tgidCell   = new TableCell();
            tgidCell.Controls.Add(s);

            detailsRow.Cells.Add(tgidCell);

            TableCell tidCell = new TableCell();
            tidCell.Text = touristInfoArr[1].ToString();
            detailsRow.Cells.Add(tidCell);

            TableCell userCell = new TableCell();
            userCell.Text = touristInfoArr[2].ToString();
            detailsRow.Cells.Add(userCell);

            viewTRListTable.Rows.Add(detailsRow);
        }
    }
Ejemplo n.º 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Tourist tr = new Tourist(Session["username"].ToString());

        String reader = tr.viewUpcomingToursTR();

        String[] readerArr = reader.Split(';');
        Array.Resize(ref readerArr, readerArr.Length - 1);

        int tuple_length = readerArr.Length + 1;
        int loops        = tuple_length / 4;

        int count = 0;

        for (int i = 0; i < loops; i++)
        {
            LinkButton s = new LinkButton();
            s.Text   = readerArr[count].ToString();
            s.Click += new EventHandler(setBookingId);

            TableRow  detailsRow = new TableRow();
            TableCell tgidCell   = new TableCell();
            tgidCell.Controls.Add(s);

            detailsRow.Cells.Add(tgidCell);

            count += 1;
            TableCell tidCell = new TableCell();
            tidCell.Text = readerArr[count].ToString();
            detailsRow.Cells.Add(tidCell);

            count += 1;
            TableCell userCell = new TableCell();
            userCell.Text = readerArr[count].ToString();
            detailsRow.Cells.Add(userCell);

            count += 1;
            TableCell r = new TableCell();
            r.Text = readerArr[count].ToString();
            detailsRow.Cells.Add(r);

            TRUpTourListTable.Rows.Add(detailsRow);
            count += 1;
        }
    }
Ejemplo n.º 24
0
 public ActionResult Edit(int ID, Tourist tourist)
 {
     try
     {
         Tourist DBtourist = db.Tourists.Where(c => c.ID == ID).FirstOrDefault();
         DBtourist.SelectedCity  = tourist.SelectedCity;
         DBtourist.Interests     = tourist.Interests;
         DBtourist.FirstName     = tourist.FirstName;
         DBtourist.LastName      = tourist.LastName;
         DBtourist.SelectedState = tourist.SelectedState;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 25
0
        public IActionResult Edit(TouristRequest Tourist)
        {
            CountryViewModel countryViewModel = new CountryViewModel();

            countryViewModel.CountryList = new SelectList(countryRepository.GetAll, "CountryId", "Name");
            if (ModelState.IsValid)
            {
                var request = new Tourist()
                {
                };
                touristRepository.Update(request);
                touristRepository.Commit();
                return(RedirectToAction(nameof(List)));
            }
            return(View(new CountryViewModel()
            {
            }));
        }
Ejemplo n.º 26
0
        public override async Task <AddRangeClientReponse> AddRangeClient(IAsyncStreamReader <ClientModel> requestStream, ServerCallContext context)
        {
            while (await requestStream.MoveNext())
            {
                Tourist client = _mapper.Map <Tourist>(requestStream.Current);
                _touristRepository.Add(client);
            }

            var insertCount = await _touristRepository.SaveChangesAsync();

            var response = new AddRangeClientReponse
            {
                Success     = insertCount > 0,
                InsertCount = insertCount
            };

            return(response);
        }
Ejemplo n.º 27
0
 public ActionResult ChangeEmergencyInfo()
 {
     if ((string)Session["userCode"] == "tourist")
     {
         int     TouristId = (int)Session["TouristId"];
         Tourist tourist   = (from c in entity.Tourists where c.TouristId == TouristId select c).FirstOrDefault();
         TouristEmergencyInfoViewModel tcevm = new TouristEmergencyInfoViewModel();
         tcevm.TouristId             = TouristId;
         tcevm.TouristEmergencyPhnNo = tourist.TouristEmergencyPhnNo;
         tcevm.TouristAddress        = tourist.TouristAddress;
         return(View(tcevm));
     }
     else
     {
         Session["user"] = "******";
         return(RedirectToAction("Index", "Home"));
     }
 }
Ejemplo n.º 28
0
        public IActionResult cancelTrip(int tourId)
        {
            int?logged_id = HttpContext.Session.GetInt32("LoggedUser");

            if (logged_id == null)
            {
                return(RedirectToAction("Index"));
            }

            Tourist remTour = dbContext.Tourists.FirstOrDefault(t => t.TouristId == tourId);

            if (remTour != null && remTour.TravellerId == (int)logged_id)
            {
                dbContext.Remove(remTour);
                dbContext.SaveChanges();
            }
            return(RedirectToAction("Dashboard"));
        }
Ejemplo n.º 29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Tour_Guide tg = new Tour_Guide(Session["username"].ToString());

        tg.setInfo();

        tourID.Text = Session["tourID"].ToString();
        Booking b      = new Booking();
        String  reader = b.getTIDbyTour(Session["tourID"].ToString()).ToString();

        String[] readerArr = reader.Split(';'); // array of tourist IDs
        Array.Resize(ref readerArr, readerArr.Length - 1);

        Tourist t = new Tourist();

        // for each tourist, get TID, first_name and last_name
        for (int i = 0; i < readerArr.Length; i++)
        {
            String   touristID      = readerArr[i].ToString();
            String   touristInfo    = t.getTouristName(touristID).ToString();
            String[] touristInfoArr = touristInfo.Split(';'); // array of TID, fname, lname
            Array.Resize(ref touristInfoArr, touristInfoArr.Length - 1);

            LinkButton s = new LinkButton();
            s.Text   = touristInfoArr[0].ToString();
            s.Click += new EventHandler(goToTourist);

            TableRow  detailsRow = new TableRow();
            TableCell tgidCell   = new TableCell();
            tgidCell.Controls.Add(s);

            detailsRow.Cells.Add(tgidCell);

            TableCell tidCell = new TableCell();
            tidCell.Text = touristInfoArr[1].ToString();
            detailsRow.Cells.Add(tidCell);

            TableCell userCell = new TableCell();
            userCell.Text = touristInfoArr[2].ToString();
            detailsRow.Cells.Add(userCell);

            viewListTRTable.Rows.Add(detailsRow);
        }
    }
Ejemplo n.º 30
0
 public ActionResult ChangeAccountEmail(TouristChangeEmailViewModel tcevm)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Tourist tourist = (from c in entity.Tourists where c.TouristId == tcevm.TouristId select c).FirstOrDefault();
             if (tourist.TouristEmail == tcevm.TouristEmail)
             {
                 return(RedirectToAction("UserPanel", "Home"));
             }
             else
             {
                 bool result = tl.CheckEmailExist(tcevm.TouristEmail);
                 if (result == true)
                 {
                     ViewData["message"] = "Email duplicacy found.";
                     return(View(tcevm));
                 }
                 else
                 {
                     tourist.TouristEmail = tcevm.TouristEmail;
                     if (entity.SaveChanges() > 0)
                     {
                         return(RedirectToAction("UserPanel", "Home"));
                     }
                     else
                     {
                         ViewData["message"] = "There's a problem going on. please try again later.";
                         return(View(tcevm));
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             return(View("Error", new HandleErrorInfo(ex, "Tourist", "ChangeAccountEmail")));
         }
     }
     else
     {
         return(View(tcevm));
     }
 }