public IHttpActionResult PutGuest(int id, Guest guest)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != guest.Id)
            {
                return BadRequest();
            }


            try
            {
                _GuestService.Update(guest);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GuestExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 2
0
        public string getGuestId()
        {
            ThreeHotelEntities2 ct = new ThreeHotelEntities2();

            Guest guest = new Guest();
            guest = (from x in ct.Guests
                     where x.GuestId.Contains("G")
                     orderby x.GuestId descending
                     select x).First();

            string a = guest.GuestId;
            string b = a.Substring(4, 1);

            int d = Convert.ToInt32(b);
            string e = Convert.ToString(d + 1);
            string c = "";
            if (d + 1 > 999)
                c = "G" + e;
            else if (d + 1 > 99)
                c = "G0" + e;
            else if (d + 1 > 9)
                c = "G00" + e;
            else
                c = "G000" + e;

            return c;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a Guest
        /// </summary>
        /// <param name="guest">Guest to create.</param>
        public void Create(Guest guest)
        {            
            guest.IsValid();

            guest.IsGuestValidForCreation();

            // Check if CountryId is specified. if not, CountryId should be defaulted to country of business.
            if (!guest.IsCountryIdSpecified())
            {
                guest.CountryId = countryDao.GetByBusiness(guest.BusinessId).Id;
            }

            using (var btx = new BusinessTransaction())
            {
                // Create Guest or throw exception for invalid Guest
                guestDao.Create(guest);

                // Create Guest event
                guestEventDao.Create(new GuestEvent
                {
                    GuestEventType = GuestEventType.Created,
                    GuestId = guest.Id.HasValue ? guest.Id.Value : 0
                });

                btx.Commit();
            }
        }
Ejemplo n.º 4
0
        public IHttpActionResult PutGuest(int id, Guest guest)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != guest.Guest_No)
            {
                return BadRequest();
            }

            db.Entry(guest).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GuestExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 5
0
 public virtual void AddGuest(Guest guest)
 {
     if (Guests.Add(guest) == false)
     {
         throw new InvalidOperationException();
     }
 }
Ejemplo n.º 6
0
        public void GetListOfEmptyRooms()
        {
            // Arrange
            IRoomAccess service = new RoomAccess();
            service.GenerateBasicHotel(3, 2, 3);

            var guest1 = new Guest(fname: "Some", lname: "Body");
            string roomNumber1 = service.GetRoomNumbers()[4];
            service.AssignGuestToRoom(guest1, roomNumber1);

            var guest2 = new Guest(fname: "Noone", lname: "Special");
            string roomNumber2 = service.GetRoomNumbers()[3];
            service.AssignGuestToRoom(guest2, roomNumber2);

            var guest3 = new Guest(fname: "Short", lname: "Timer");
            string roomNumber3 = service.GetRoomNumbers()[5];
            service.AssignGuestToRoom(guest3, roomNumber3);
            service.UnassignGuestFromRoom(guest3, roomNumber3);

            // Act
            List<Room> list = service.GetAllEmptyRooms();

            // Assert
            Assert.AreEqual(3*2*3 - 2, list.Count, "Expected number of empty rooms incorrect");
            Assert.IsTrue(list.All(room => room.Guest == null), "Not all rooms returned are empty");
        }
Ejemplo n.º 7
0
        public void GetListOfGuests()
        {
            // Arrange
            IRoomAccess service = new RoomAccess();
            service.GenerateBasicHotel(3, 2, 3);

            var guest1 = new Guest(fname: "Some", lname: "Body");
            string roomNumber1 = service.GetRoomNumbers()[4];
            service.AssignGuestToRoom(guest1, roomNumber1);

            var guest2 = new Guest(fname: "Noone", lname: "Special");
            string roomNumber2 = service.GetRoomNumbers()[3];
            service.AssignGuestToRoom(guest2, roomNumber2);

            var guest3 = new Guest(fname: "Short", lname: "Timer");
            string roomNumber3 = service.GetRoomNumbers()[5];
            service.AssignGuestToRoom(guest3, roomNumber3);
            service.UnassignGuestFromRoom(guest3, roomNumber3);

            // Act
            List<Guest> list = service.GetGuestList();

            // Assert
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual(1, list.FindAll(guest => guest.FirstName == "Some" && guest.LastName == "Body").Count);
            Assert.AreEqual(1, list.FindAll(guest => guest.FirstName == "Noone" && guest.LastName == "Special").Count);
        }
Ejemplo n.º 8
0
        public IHttpActionResult PostGuest(Guest guest)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Guests.Add(guest);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (GuestExists(guest.Guest_No))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = guest.Guest_No }, guest);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Used to help with tests, creates a simple booking given the Guest
 /// All data set to 1. Start - End is 1/4/2020 - 2/6/2020
 /// Created by user guestId is b7e6f3a3-401f-4179-b9ca-f429bb891ea6
 /// </summary>
 /// <param name="guest">Guest to use for booking creation, defaults to null if not specified</param>
 /// <param name="isTentative">True if a tentative booking is wanted, false for confirmed booking, defaults to true if not specified</param>
 /// <returns>booking with basic information input</returns>
 public static Booking SetupSimpleBooking(Guest guest = null, bool isTentative = true)
 {
     return new Booking
         {
             Id = 1,
             OrderId = 1,
             BookingReferenceNumber = "1",
             BusinessId = 1,
             RoomId = 1,
             RoomTypeId = 1,
             RatePlanId = 1,
             Guest = guest ?? Guest,
             NumberOfAdults = 1,
             NumberOfChildren = 0,
             BookingStatus = isTentative ? new EnumEntity { Code = BookingStatusType.TENTATIVE } : new EnumEntity { Code = BookingStatusType.CONFIRMED },
             Cost = 10,
             StartDate = new DateTime(2020, 4, 1, 0, 0, 0, DateTimeKind.Utc),
             EndDate = new DateTime(2020, 6, 2, 0, 0, 0, DateTimeKind.Utc),
             BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking,
             RateType = new EnumEntity { Code = RateType.BEST_AVAILABLE_RATE },
             CancellationDetails = new CancellationDetail
             {
                 CancellationCharge = 0
             }
         };
 }
Ejemplo n.º 10
0
	void InitGuest(Guest guest)
	{
		int rand = UnityEngine.Random.Range (0,2);
		//if(rand == 0)
		guest.Init( GetRandomizedGuestType(), GetRandomizedJewelType(), GetRamdomizedQuantity(),_currentOrderNo ++);
		//else
			//guest.Init( GetRandomizedGuestType(), GetRandomizedItemType() );
	}
Ejemplo n.º 11
0
 public void CheckoutGuest(Guest guest, string roomNumber)
 {
     if (roomNumber != null) {
         using (var roomAccess = _ioc.Resolve<IRoomAccess>()) {
             roomAccess.UnassignGuestFromRoom(Repackage.Guest(guest), roomNumber);
         }
     }
 }
Ejemplo n.º 12
0
 public Room CheckinGuest(Guest guest, string roomNumber = null)
 {
     if (roomNumber == null) {
         using (var reservingEngine = _ioc.Resolve<IReservingEngine>()) {
             return Repackage.Room(reservingEngine.PerformAutoCheckin(Repackage.Guest(guest)));
         }
     }
     return null;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Maps the guests.
 /// </summary>
 /// <param name="guest">The guest.</param>
 /// <param name="alerts">The alerts.</param>
 /// <param name="personAlerts">The person alerts.</param>
 /// <param name="alertTypeList">The alert Type Master List.</param>
 internal static void MapGuests(Guest guest, ListResult<DataAccess.Entities.Alert> alerts, ListResult<DataAccess.Entities.PersonAlert> personAlerts, ListResult<DataAccess.Entities.AlertType> alertTypeList)
 {
     var alertCollection = AlertMapper.MapCollection(alerts.Items, personAlerts.Items, guest.GuestId, alertTypeList);
     if (alertCollection != null && alertCollection.Count > 0)
     {
         guest.HasAlert = true;
         guest.AssignAlerts(alertCollection);
     }
 }
Ejemplo n.º 14
0
 public void Cant_add_two_same_guests()
 {
     var duration = new DayDuration(new DateTime(2016, 2, 10), new DateTime(2016, 2, 11));
     var reservation = new Reservation(null, null, duration);
     var guestOne = new Guest("Test", "Test");
     var guestTwo = new Guest("Test", "Test");
     reservation.AddGuest(guestOne);
     reservation.Invoking(x => x.AddGuest(guestTwo)).ShouldThrow<InvalidOperationException>();
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Maps the guests.
 /// </summary>
 /// <param name="guest">The guest.</param>
 /// <param name="personMessages">The messages.</param>
 /// <param name="messageTypeList">The message Type Master List.</param>
 internal static void MapGuests(Guest guest, ListResult<DataAccess.Entities.PersonMessage> personMessages, ListResult<DataAccess.Entities.MessageType> messageTypeList)
 {
     var messageCollection = MessageMapper.MapCollection(personMessages.Items, guest.GuestId, messageTypeList);
     if (messageCollection != null && messageCollection.Count > 0)
     {
         guest.HasMessage = true;
         guest.AssignMessages(messageCollection);
     }
 }
Ejemplo n.º 16
0
	public void RefillGuest(Guest guest)
	{
		if (_numQueue <= 0)
			return;

		_numQueue --;

		InitGuest (guest);
	}
Ejemplo n.º 17
0
 public void MustSetDefaultPropertyOnError() 
 {
     var guestFilter = new GuestFilter();
     guestFilter.SetSortingCol("88");
     var guestName = "Name of the guest";
     var guestMail = "*****@*****.**";
     var guest = new Guest(guestName, guestMail);
     var prop = guestFilter.GetSortingProp(guest);
     Assert.IsTrue(prop.ToString() == guestName);        
 }
Ejemplo n.º 18
0
        public Guest getByMemberId(string id)
        {
            ThreeHotelEntities2 ct = new ThreeHotelEntities2();
            Guest guest = new Guest();

            guest = (from x in ct.Guests
                     where x.GuestId == id
                     select x).First();

            return guest;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Maps the asynchronous.
        /// </summary>
        /// <param name="guestEntity">The guest entities.</param>
        /// <returns>Return instance of Guest.</returns>
        private static Guest MapAsync(Entities.Guest guestEntity)
        {
            var guest = new Guest();

            if (guestEntity != null)
            {
                guest.GuestId = guestEntity.GuestId;
                guest.GuestReservationId = guestEntity.GuestReservationId;
                guest.PersonalDetail = guestEntity.PersonalDetail;
                guest.CruiseDetail = guest.CruiseDetail ?? new GuestCruiseDetail();
                if (guestEntity.ReservationDetail != null)
                {
                    guest.CruiseDetail.IsPrimary = guestEntity.ReservationDetail.IsPrimary;
                    guest.CruiseDetail.LoyaltyLevelTypeId = guestEntity.ReservationDetail.LoyaltyLevelTypeId;
                    guest.CruiseDetail.ReservationId = guestEntity.ReservationDetail.ReservationId;
                    guest.CruiseDetail.ReservationNumber = guestEntity.ReservationDetail.ReservationNumber;
                    guest.CruiseDetail.ReservationStatusId = guestEntity.ReservationDetail.ReservationStatusId;
                    guest.CruiseDetail.Stateroom = guestEntity.ReservationDetail.StateroomId;
                    guest.CruiseDetail.EmbarkDate = guestEntity.ReservationDetail.ReservationFromDate;
                    guest.CruiseDetail.DebarkDate = guestEntity.ReservationDetail.ReservationToDate;
                    guest.CruiseDetail.VoyageId = guestEntity.ReservationDetail.VoyageId;
                    guest.CruiseDetail.CanDebarkAlone = guest.PersonalDetail != null && guest.PersonalDetail.Age.HasValue && guest.PersonalDetail.Age.Value >= ApplicationSetting.MaximumChildAge;
                }

                guest.PersonalDetail = guest.PersonalDetail ?? new PersonalDetail();

                var passportDetail = guestEntity.Identifications.FirstOrDefault(a => a.DocumentTypeId.Equals(ApplicationSetting.DocumentTypeId, StringComparison.OrdinalIgnoreCase));
                if (passportDetail != null)
                {
                    guest.PersonalDetail.DocumentNumber = passportDetail.Number;
                    guest.PersonalDetail.DocumentTypeId = passportDetail.DocumentTypeId;
                }
                else
                {
                    var identificationDetail = guestEntity.Identifications.FirstOrDefault();
                    if (identificationDetail != null)
                    {
                        guest.PersonalDetail.DocumentNumber = identificationDetail.Number;
                        guest.PersonalDetail.DocumentTypeId = identificationDetail.DocumentTypeId;
                    }
                }

                var mediaItem = guestEntity.MediaItems.FirstOrDefault(a => a.MediaTypeId.Equals(ApplicationSetting.MediaTypeId, StringComparison.OrdinalIgnoreCase));
                guest.SecurityPhotoAddress = mediaItem != null ? mediaItem.MediaItemAddress : null;

                if (guestEntity.Folios.Count > 0)
                {
                    guest.AssignFolios(guestEntity.Folios);
                }
            }

            return guest;
        }
        private void GuestAdded(Guest guest)
        {
            if (guest.uniqueID == 208)
            {
                _timPresent = true;
            }

            if (guest.uniqueID == 209)
            {
                _luukPresent = true;
            }
        }
        public RoomReservationViewModel()
        { RoomReservation_SponsorViewModel = new RoomReservation_SponsorViewModel();
        //default 1 RoomReservation_RoomDetailsViewDetail;
        RoomReservation_RoomDetailsViewDetailList = new List<RoomReservation_RoomDetailsViewDetail>();
        RoomReservation_RoomDetailsViewDetail room_detailviewmodel= new RoomReservation_RoomDetailsViewDetail();
        RoomReservation_RoomDetailsViewDetailList.Add(room_detailviewmodel);
        Guest = new Guest();
        Guest_DocumentsViewModel = new Guest_DocumentsViewModel();

        RoomReservation_Payment = new RoomReservation_Payment();
        Reservation_Total_OtherCurrency = 0; 
        }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            User[] arrUser = new User[2];

            arrUser[0] = new Guest();
            arrUser[1] = new Admin();

            foreach (User u in arrUser)
            {
                Console.WriteLine(u.GetRoles());
            }
            
        }
Ejemplo n.º 23
0
 public int CreateNewGuest(string ip, string userAgent) {
     return InvokeSafe(() => {
         if (UserAgentValidationPolicy.IsBot(userAgent)) {
             return UserAgentValidationPolicy.BOT_GUID;
         }
         var guid = new Guest {
             Datecreated = DateTime.UtcNow,
             Ip = ip
         };
         guid.Save();
         return guid.ID;
     }, UserAgentValidationPolicy.BOT_GUID);
 }
        public void CheckInGuestIntoNonExistantRoom()
        {
            // Arrange
            IRoomAccess service = new RoomAccess();
            service.GenerateBasicHotel(2, 2, 2);
            var guest = new Guest(fname: "Some", lname: "Body");
            string roomNumber = "IAmNotARoom";

            // Act
            service.AssignGuestToRoom(guest, roomNumber);

            // Assert
            Assert.Fail("Expected exception was not thrown");
        }
Ejemplo n.º 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Id"] != null)
            {
                LinkButton2.Text = "SignOut";

                //get member name to display on Welcome
                Guest guest = new Guest();
                GuestController guestController = new GuestController();
                guest = guestController.getByMemberId(Session["Id"].ToString());
                string name = guest.Salutation + guest.FirstName + guest.FamilyName;
                lblWelcome.Text = "Welcome, " + name;
            }
        }
Ejemplo n.º 26
0
 public static IList<Guest> Create(int amount)
 {
     IList<Guest> guests = new List<Guest>();
     for (var i = 1; i <= amount; i++)
     {
         var guestName = RandomInfoGenerator.GenerateRandomName(i);
         var guest = new Guest(guestName, RandomInfoGenerator.GenerateMailAddressFromName(guestName));
         guest.Country = RandomInfoGenerator.GetRandomCountry(i);
         guest.Anniversary = RandomInfoGenerator.GenerateRandomDate(guest.Name);
         guest.Gender = RandomInfoGenerator.GetRandomGender(i);
         guests.Add(guest);
     }
     return guests;
 }
        public void CheckInGuestIntoEmptyRoom()
        {
            // Arrange
            IRoomAccess service = new RoomAccess();
            service.GenerateBasicHotel(2, 2, 2);
            var guest = new Guest(fname: "Some", lname: "Body");
            string roomNumber = service.GetRoomNumbers()[4];

            // Act
            service.AssignGuestToRoom(guest, roomNumber);

            // Assert
            Assert.AreEqual("Some", RoomAccess.HotelMap.Find(room => room.RoomNumber == roomNumber).Guest.FirstName, "Assigned guest's first name doesn't match");
            Assert.AreEqual("Body", RoomAccess.HotelMap.Find(room => room.RoomNumber == roomNumber).Guest.LastName, "assigned guest's last name doesn't match");
            Assert.IsTrue(RoomAccess.HotelMap.FindAll(room => room.RoomNumber != roomNumber).TrueForAll(room => room.Guest == null),
                          "Guest assigned to wrong rooms");
        }
Ejemplo n.º 28
0
            public void TestGetByOrderIdAndReferenceTypeReturnsData()
            {
                // arrange
                var guest = new Guest
                {
                    BusinessId = BUSINESS_ID,
                    DefaultCultureCode = "en-GB",
                    AddressLine1 = "AL1",
                    City = "City",
                    Forename = "Bob",
                    Surname = "Smith"
                };

                guestManager.Create(guest);

                var mockOrder = new Order
                {
                    IntegrationType = IntegrationTypeEnum.Myweb,
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    CustomerCurrencyCode = "GBP",
                    OrderSourceCode = SourceType.Online.GetCode(),
                    LeadGuest = guest,
                    LeadGuestId = guest.Id.Value
                };

                orderDao.CreateOrder(BUSINESS_ID, mockOrder);
                Assert.IsTrue(mockOrder.Id.HasValue, "Test order was not created");

                var mockOrderReference = new OrderReference
                                             {
                                                 OrderId = mockOrder.Id.Value,
                                                 Reference = Guid.NewGuid().ToString(),
                                                 ReferenceTypeCode = ReferenceTypeEnum.EcommerceReservation.GetCode()
                                             };

                orderReferenceDao.Create(mockOrderReference);
                Assert.IsTrue(mockOrder.Id.HasValue, "Test order reference was not created");

                // act
                var resultOrderReference = orderReferenceDao.GetByOrderIdAndReferenceType(mockOrder.Id.Value, ReferenceTypeEnum.EcommerceReservation);

                // assert
                Assert.IsNotNull(resultOrderReference, "Order reference object has not been returned.");
                Assert.AreEqual(mockOrderReference.Id, resultOrderReference.Id, "Order reference ids do not match");
            }
Ejemplo n.º 29
0
        private void EnterGuest(Guest guest)
        {
            if (_isInGuest)
                return;

            UIWorldOverlayController.Instance.gameObject.SetActive(false);
            Camera.main.GetComponent<CameraController>().enabled = false;

            _camera = new GameObject();
            _camera.AddComponent<Camera>().nearClipPlane = 0.05f;
            _camera.AddComponent<AudioListener>();
            _camera.transform.parent = guest.head.transform;
            _camera.transform.localPosition = new Vector3(-0.09f, -0.13f, 0);
            _camera.transform.localRotation = Quaternion.Euler(90, 0, 90);

            _isInGuest = true;

            ApplySettings();
        }
Ejemplo n.º 30
0
            public void CreateOrderEventIsSuccessful()
            {
                // Arrange
                var orderDao = new OrderDao();
                GuestManager guestManager = new GuestManager();
                Guest guest = new Guest
                {
                    BusinessId = BUSINESS_ID,
                    DefaultCultureCode = "en-GB",
                    AddressLine1 = "AL1",
                    City = "City",
                    Forename = "Bob",
                    Surname = "Smith"
                };
                guestManager.Create(guest);

                var mockOrder = new Order
                    {
                        IntegrationType = IntegrationTypeEnum.Myweb,
                        OfflineSourceEnum = OfflineSourceEnum.Web,
                        CustomerCurrencyCode = "GBP",
                        OrderSourceCode = SourceType.Online.GetCode(),
                        LeadGuest = guest,
                        LeadGuestId = guest.Id.Value
                    };
                
                orderDao.CreateOrder(BUSINESS_ID, mockOrder);

                Assert.IsTrue(mockOrder.Id.HasValue);

                var orderEvent = new OrderEvent
                    {
                        OrderId = mockOrder.Id.Value,
                        EventType = new Model.Core.EnumEntity { Code = OrderEventTypeEnum.OrderCreated.GetCode() }
                    };

                // Act
                orderEventDao.Create(orderEvent);

                // Assert
                Assert.IsTrue(orderEvent.Id > 0, "Id was not filled in after create");
            }
        /// <summary author="Alisa Roehr" created="2019/02/15">
        /// Modified: 2019/03/01
        ///
        /// Check if guest is valid or not
        /// </summary>
        /// <updates>
        /// <update author = "Alisa Roehr" date="2019/04/16 ">
        /// Made it so that other extentions can be used for email.
        /// </update>
        /// </updates>
        /// <param name="_guest"> guest that is being tested for validation</param>
        /// <returns>whether the guest information is valid</returns>
        public bool isValid(Guest _guest)
        {
            int aNumber;

            if (_guest.MemberID.ToString().Length > 11 || _guest.MemberID == null || _guest.MemberID == 0)
            {
                return(false);               // for member id
            }
            if (_guest.GuestTypeID.Length > 25 || _guest.GuestTypeID == null || _guest.GuestTypeID.Length == 0)
            {
                return(false);                // for guest type
            }
            else if (_guest.FirstName.Length > 50 || _guest.FirstName == null || _guest.FirstName.Length == 0 || _guest.FirstName.Any(c => char.IsDigit(c)))
            {
                return(false);                // for first name
            }
            else if (_guest.LastName.Length > 100 || _guest.LastName == null || _guest.LastName.Length == 0 || _guest.LastName.Any(c => char.IsDigit(c)))
            {
                return(false);                // for last name
            }
            else if (_guest.PhoneNumber.Length > 11 || _guest.PhoneNumber == null || _guest.PhoneNumber.Length == 0)
            {
                return(false);                 // for phone number
            }
            else if (_guest.Email.Length > 250 || _guest.Email == null || _guest.Email.Length == 0 || !_guest.Email.Contains("@") || !_guest.Email.Contains("."))
            {
                return(false);                 // for email, need greater email validation
            }
            else if (_guest.Minor == null)
            {
                return(false);                // for minor
            }
            else if (_guest.Active == null)
            {
                return(false);                // for active
            }
            else if (_guest.ReceiveTexts == null)
            {
                return(false);                // for ReceiveTexts
            }
            else if (_guest.EmergencyFirstName.Length > 50 || _guest.EmergencyFirstName == null || _guest.EmergencyFirstName.Length == 0 || _guest.EmergencyFirstName.Any(c => char.IsDigit(c)))
            {
                return(false);                // for EmergencyFirstName
            }
            else if (_guest.EmergencyLastName.Length > 100 || _guest.EmergencyLastName == null || _guest.EmergencyLastName.Length == 0 || _guest.EmergencyLastName.Any(c => char.IsDigit(c)))
            {
                return(false);                // for EmergencyLastName
            }
            else if (_guest.EmergencyPhoneNumber.Length > 11 || _guest.EmergencyPhoneNumber == null || _guest.EmergencyPhoneNumber.Length < 7)
            {
                return(false);                // for EmergencyPhoneNumber, need to test for if integer
            }
            else if (_guest.EmergencyRelation.Length > 25 || _guest.EmergencyRelation == null || _guest.EmergencyRelation.Length == 0)
            {
                return(false);                // for EmergencyRelation
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 32
0
        public async Task <IActionResult> AddGuest([FromBody] Guest model, double balance)
        {
            var result = await this._service.AddGuest(model, balance);

            return(Ok(result));
        }
Ejemplo n.º 33
0
 public Template ParseTemplate(Guest guest)
 {
     return(new Template());
 }
Ejemplo n.º 34
0
 // PUT: api/Guests/5
 public bool Put(int id, [FromBody] Guest guest)
 {
     return(manager.Put(id, guest));
 }
Ejemplo n.º 35
0
        public List <Guest> GuestSearch(Guest guest, string searchKey)
        {
            string sqlSelectQuery = "";

            if ("GuestMobile".Equals(searchKey))
            {
                sqlSelectQuery =
                    "select GuestName,GuestMobile,PaymentDate,PaymentAmount,ReceiptNumber,PaymentMode,CollectedBy,ts.SlotName,Court,Notes from GuestPayment gp inner join TimeSlotMaster ts on gp.Timeslot = ts.SlotId where GuestMobile=@searchvalue order by PaymentDate desc";
            }

            SqlCommand   sqlCommand    = null;
            List <Guest> guestPayments = new List <Guest>();

            try
            {
                using (SqlConnection connection =
                           new SqlConnection(CommonUtility.Sqlconnectionstring))
                {
                    sqlCommand = new SqlCommand(sqlSelectQuery, connection);
                    if ("GuestMobile".Equals(searchKey))
                    {
                        sqlCommand.Parameters.AddWithValue("@searchvalue", guest.GuestMobile);
                    }

                    sqlCommand.Connection.Open();
                    SqlDataReader reader = sqlCommand.ExecuteReader();

                    while (reader.Read())
                    {
                        var    objDateTime       = (DateTime)reader[2];
                        string memberPaymentDate = objDateTime.ToString("dd-MMM-yyyy");

                        Guest objGuest = new Guest
                        {
                            GuestName     = reader[0] + "",
                            GuestMobile   = reader[1] + "",
                            PaymentDate   = memberPaymentDate,
                            PaymentAmount = reader[3] + "",
                            ReceiptNumber = reader[4] + "",
                            PaymentMode   = reader[5] + "",
                            CollectedBy   = reader[6] + "",
                            GuestTimeslot = reader[7] + "",
                            GuestCourt    = reader[8] + "",
                            Notes         = reader[9] + ""
                        };
                        guestPayments.Add(objGuest);
                    }

                    reader.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                sqlCommand?.Connection?.Close();
            }

            return(guestPayments);
        }
        private void btnAddGuests_Click(object sender, EventArgs e)
        {
            int secilenOdaNumarasi = Convert.ToInt32(cmbRooms.SelectedValue);
            int BookDetailsID      = _bookDetailsIDs[cmbRooms.SelectedIndex];

            #region Validations
            bool bosVarMi = false;
            foreach (var item in grpAddGuestInfo.Controls)
            {
                if (item is TextBox)
                {
                    if ((item as TextBox).Text == "")
                    {
                        bosVarMi = true;
                    }
                }
            }

            if (bosVarMi == true)
            {
                MessageBox.Show("Lütfen misafir bilgileriyle alakalı tüm alanları doldurunuz");
                return;
            }

            var OdadakiKisilerinTCNumaraları = _db.Guests.Where(x => x.BookDetailsID == BookDetailsID).Select(x => x.GuestPersonelID).ToList();
            if (OdadakiKisilerinTCNumaraları.Contains(txtGuestPersonID.Text))
            {
                MessageBox.Show("Aynı TC numarasıyla sadece 1 adet misafir kaydı yapılabilir");
                return;
            }

            var rezervasyonIDsi = _db.BookDetails.Where(x => x.BookDetailsID == BookDetailsID).Select(x => x.BookID).FirstOrDefault();
            var rezervasyonYapılanTümKisilerinIDleri = _db.BookDetails
                                                       .Join(_db.Guests, bd => bd.BookDetailsID, g => g.BookDetailsID,
                                                             (bd, g) => new { bd, g })
                                                       .Where(x => x.bd.BookID == rezervasyonIDsi)
                                                       .Select(x => x.g.GuestPersonelID).ToList();

            if (txtGuestPersonID.TextLength != 11)
            {
                MessageBox.Show("Tc Numarasını eksik ve ya hatalı girdiniz....");
                return;
            }
            if (rezervasyonYapılanTümKisilerinIDleri.Contains(txtGuestPersonID.Text))
            {
                MessageBox.Show("Bu kişinin odalardan birine zaten kaydı var lütfen başka bir TC numaralı kişi ekleyiniz ");
                return;
            }
            if (_odalaraEklenenKisiSayisi >= _personCount)
            {
                MessageBox.Show("İstediğiniz gibi" + _personCount + " kişilik rezervasyon tamamlanmıştır.Yeni bir misafir eklemek istiyorsanız lütfen rezervasyon işlemini yeniden başlatıp kişi sayısını arttırınız. ");
                return;
            }


            #endregion

            var aynıOdadaKayıtlıKisiSayisi = _db.Guests.Where(x => x.BookDetailsID == BookDetailsID).Count();

            var seciliOdaTipi = _db.Rooms.Where(x => x.RoomNumber == secilenOdaNumarasi).Select(x => x.RoomTypeID).FirstOrDefault();

            var seciliOdaKapasitesi = _db.RoomDetails.Where(x => x.RoomTypeID == seciliOdaTipi).Select(x => x.RoomCapacity).FirstOrDefault();



            if (seciliOdaKapasitesi > aynıOdadaKayıtlıKisiSayisi)
            {
                Guest g1 = new Guest();
                g1.BookDetailsID   = BookDetailsID;
                g1.GuestFirstName  = txtGuestName.Text;
                g1.GuestLastName   = txtGuestSurname.Text;
                g1.GuestPersonelID = txtGuestPersonID.Text;
                _db.Guests.Add(g1);
                lstGuests.Items.Add(g1.GuestPersonelID);
                _db.SaveChanges();
                _odalaraEklenenKisiSayisi++;
            }
            else
            {
                MessageBox.Show("Oda kapasitesi dolmuştur");
                return;
            }
            TextBoxsClear();
        }
Ejemplo n.º 37
0
 // PUT: api/Guests/5
 public bool Put(int id, [FromBody] Guest g)
 {
     return(mgr.Put(id, g));
 }
 public bool Post([FromBody] Guest value)
 {
     return(_mngeGuest.CreateGuest(value));
 }
        public async Task <IActionResult> BookPlace(Guest guest, string dateVisit, Place place, int placeId)
        {
            long num = 0;

            ViewBag.DateVisit = Convert.ToDateTime(dateVisit);
            ViewBag.Place     = new Place
            {
                Id            = placeId,
                NumberOfSeats = place.NumberOfSeats,
                TableNumber   = place.TableNumber
            };
            if (User.IsInRole("user"))
            {
                ViewBag.GuestEmail = User.Identity.Name;
            }
            if (guest.DateVisit < DateTime.Now.Date)
            {
                ModelState.AddModelError("DateVisit", "Enter correct Date");
            }
            else
            if (guest.Time1 > guest.Time2)
            {
                ModelState.AddModelError("Time1", "Time1 must be less than Time2");
            }
            else
            if (long.TryParse(guest.Phone, out num) == false)
            {
                ModelState.AddModelError("Phone", "Phone must contains only digits");
            }
            else
            if (ModelState.IsValid)
            {
                var  list = guestRepository.GetGuestsByDateAndTable(guest.DateVisit, guest.SelectedTable);
                bool f    = false;
                foreach (var item in list)
                {
                    if ((item.Time1 < guest.Time1 && guest.Time2 < item.Time2) ||
                        (!(guest.Time1 <= item.Time1 && guest.Time2 <= item.Time1)) &&
                        (!(item.Time2 <= guest.Time1 && item.Time2 <= guest.Time2)))
                    {
                        f = true;
                    }
                    if (f)
                    {
                        break;
                    }
                }
                if (f)
                {
                    ModelState.AddModelError("Time1", "Current Time is booked");
                }
                if (ModelState.IsValid)
                {
                    await guestRepository.AddGuest(guest);

                    SendingEmailAfterBooking Email = new SendingEmailAfterBooking();
                    await Email.SendEmailAsync(guest);

                    return(RedirectToRoute(new { Controller = "Home", Action = "Index", dateVisit = dateVisit }));
                }
            }
            return(View());
        }
Ejemplo n.º 40
0
 public static async Task AddSingleGuestAsync(Guest newGuest)
 {
 }
 public bool Put(int id, [FromBody] Guest value)
 {
     return(_mngeGuest.UpdateGuest(value, id));
 }
Ejemplo n.º 42
0
 public GuestDto(Guest guest)
 {
     Id       = guest.Id;
     Name     = guest.Name;
     LastName = guest.LastName;
 }
        public ActionResult UpdateAttd()
        {
            string attendanceId   = Request.Form["Attendance"];
            string GuestIdForAttd = Request.Form["GuestIdForAttd"];
            string FromPage       = Request.Form["FromPage"];

            if (attendanceId == null)
            {
                attendanceId = "0";
            }

            char[]   delimiterChars      = { ' ', ',', '.', ':', '\t' };
            string[] arrayGuestIdForAttd = GuestIdForAttd.Split(delimiterChars);
            string[] arrayAttendance     = attendanceId.Split(delimiterChars);
            bool     foundFlag           = false;

            GuestListViewModel guestListViewModel = new GuestListViewModel();
            GuestBusinessLayer guestBusinessLayer = new GuestBusinessLayer();

            if (attendanceId != "0")
            {
                for (int i = 0; i < arrayGuestIdForAttd.Length; i++)
                {
                    foundFlag = false;
                    for (int j = 0; j < arrayAttendance.Length; j++)
                    {
                        if (arrayGuestIdForAttd[i] == arrayAttendance[j])
                        {
                            guestBusinessLayer.SetAttd(arrayGuestIdForAttd[i]);
                            foundFlag = true;
                        }
                    }
                    if (!foundFlag)
                    {
                        guestBusinessLayer.DelAttd(arrayGuestIdForAttd[i]);
                    }
                }
            }
            else if (attendanceId == "0")
            {
                for (int i = 0; i < arrayGuestIdForAttd.Length; i++)
                {
                    guestBusinessLayer.DelAttd(arrayGuestIdForAttd[i]);
                }
            }

            Guest guests = new Guest();
            List <GuestViewModel> mylist = new List <GuestViewModel>();

            foreach (string s in arrayGuestIdForAttd)
            {
                GuestViewModel guestViewModel = new GuestViewModel();
                guests = guestBusinessLayer.FindGuestsById(int.Parse(s));
                guestViewModel.Name       = guests.Name;
                guestViewModel.GuestId    = guests.GuestId.ToString();
                guestViewModel.ContactNo  = guests.ContactNo;
                guestViewModel.TableNo    = guests.TableNo;
                guestViewModel.Attendance = guests.Attendance;
                mylist.Add(guestViewModel);
            }
            guestListViewModel.Guest = mylist;

            if (FromPage == "ManageGuestList")
            {
                return(View("ManageGuestList", guestListViewModel));
            }
            else
            {
                return(View("Index", guestListViewModel));
            }
        }
Ejemplo n.º 44
0
 public virtual Destination GetDestination(Vector3 vec, Guest guest)
 {
     return(_destination);
 }
        public void Add(Guest aGuest)
        {
            string vSQL = "insert into Guests (name, email, phone, WillAttend) values(@Name, @Email, @Phone, @WillAttend)";

            Execute(vSQL, aGuest);
        }
Ejemplo n.º 46
0
 /// <summary>
 /// Removes a like from a post
 /// </summary>
 /// <param name="guest">Guest that unliked the post</param>
 /// <param name="post">Post that got unliked</param>
 /// <returns>true if succesfull</returns>
 public bool Unlike(Guest guest, Post post)
 {
     return(_context.RemoveLikeFromPost(post, guest.ID));
 }
        public async Task <IActionResult> UploadRazorsEdgeExport(List <IFormFile> files)
        {
            long size     = files.Sum(f => f.Length);
            var  filePath = Path.GetTempFileName();

            // save the uploaded file to a temp file
            foreach (var formFile in files)
            {
                if (formFile.Length > 0)
                {
                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        await formFile.CopyToAsync(stream);
                    }
                }
            }
            // process the file
            FileInfo file = new FileInfo(filePath);

            using (ExcelPackage package = new ExcelPackage(file))
            {
                ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                int            numRows   = worksheet.Dimension.Rows;
                int            numCols   = worksheet.Dimension.Columns;
                for (int row = 2; row <= numRows; row++)
                {
                    string[] cells = new string[numCols];
                    for (int col = 1; col <= numCols; col++)
                    {
                        var    cellValue = worksheet.Cells[row, col].Value;
                        string cell;
                        if (cellValue == null)
                        {
                            cell = "";
                        }
                        else
                        {
                            cell = cellValue.ToString();
                        }
                        cells[col - 1] = cell;
                    }
                    if (!cells[0].Equals(""))
                    {
                        Guest g = new Guest {
                            Name = cells[0] + " " + cells[1]
                        };
                        _context.Add(g);
                    }
                    else if (!cells[5].Equals(""))
                    {
                        Sponsor s = new Sponsor {
                            Name = cells[5]
                        };
                        _context.Add(s);
                    }
                }
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 48
0
        /// <summary>
        /// Adds a report to a post
        /// </summary>
        /// <param name="guest">Guest that reported the post</param>
        /// <param name="post">Post that got reported</param>
        /// <param name="reason">Reason of guest to report the post</param>
        /// <returns>true if Report was successfully entered</returns>
        public bool Report(Guest guest, Post post, string reason)
        {
            var report = new Report(guest.ID, post.ID, reason, DateTime.Now);

            return(_reportContext.Insert(report) != null);
        }
Ejemplo n.º 49
0
        /// <summary>
        /// Obtiene el listado de Grupos de Huespedes segun la busqueda indicada
        /// </summary>
        /// <param name="guest">Model.Guest con datos para la busqueda</param>
        /// <param name="guestsGroup">Model.GuestsGroup con datos para la busqueda</param>
        /// <history>
        /// [ecanul]  28-03-2016 Created
        /// [ecanul] 17/06/2016 Modified. Implementado Asincronia
        /// </history>
        public async static Task <List <GuestsGroup> > GetGuestsGroups(Guest guest, GuestsGroup guestsGroup)
        {
            List <GuestsGroup> lstGuestsGroups = new List <GuestsGroup>();
            await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    //lstGuestsGroups = new List<GuestsGroup>();
                    if (guestsGroup.gxID != 0) //Si mandan el ID del Grupo
                    {
                        lstGuestsGroups = (from gg in dbContext.GuestsGroups
                                           where gg.gxID == guestsGroup.gxID
                                           select gg).Distinct().ToList();
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(guestsGroup.gxN))//Si envian el nombre del grupo
                        {
                            lstGuestsGroups = (from gu in dbContext.Guests
                                               from ggi in gu.GuestsGroups
                                               join gg in dbContext.GuestsGroups
                                               on ggi.gxID equals gg.gxID
                                               where gg.gxN.Contains(guestsGroup.gxN) &&
                                               (gu.guCheckInD >= guest.guCheckInD && gu.guCheckInD <= guest.guCheckOutD)
                                               select gg).Distinct().ToList();
                        }
                        else if (guest.guID != 0) //Si se manda el ID de Guest
                        {
                            lstGuestsGroups = (from gu in dbContext.Guests
                                               from ggi in gu.GuestsGroups
                                               join gg in dbContext.GuestsGroups
                                               on ggi.gxID equals gg.gxID
                                               where gu.guID == guest.guID &&
                                               (gu.guCheckInD >= guest.guCheckInD && gu.guCheckInD <= guest.guCheckOutD)
                                               select gg).Distinct().ToList();
                        }
                        //Si se manda Last o First name 1 o 2 (Solo se valida LastName1 porque es el unico que recibe informacuion de la interfaz
                        else if (!string.IsNullOrEmpty(guest.guLastName1))
                        {
                            lstGuestsGroups = (from gu in dbContext.Guests
                                               from ggi in gu.GuestsGroups
                                               join gg in dbContext.GuestsGroups
                                               on ggi.gxID equals gg.gxID
                                               //se usa solo guLastName1 por que es el campo en el que se manda todo el texto
                                               where gu.guLastName1.Contains(guest.guLastName1) || gu.guFirstName1.Contains(guest.guLastName1) ||
                                               gu.guLastname2.Contains(guest.guLastName1) || gu.guFirstName2.Contains(guest.guLastName1) &&
                                               (gu.guCheckInD >= guest.guCheckInD && gu.guCheckInD <= guest.guCheckOutD)
                                               select gg).Distinct().ToList();
                        }
                        else//Si no puso nada en los texbox se hace una busqueda unicamente entre el rango de fechas
                        {
                            lstGuestsGroups = (from gu in dbContext.Guests
                                               from ggi in gu.GuestsGroups
                                               join gg in dbContext.GuestsGroups
                                               on ggi.gxID equals gg.gxID
                                               //Se usa guCheckOutD que trae la "guest" pero en realidad deberia ser otro rango de fechas para guCheckInD
                                               where gu.guCheckInD >= guest.guCheckInD && gu.guCheckInD <= guest.guCheckOutD
                                               select gg).Distinct().ToList();
                        }
                    }
                }
            });

            return(lstGuestsGroups);
        }
Ejemplo n.º 50
0
 /// <summary>
 /// Adds a like to the a post
 /// </summary>
 /// <param name="guest">Guest that liked the post</param>
 /// <param name="post">Post that got liked</param>
 /// <returns>true if succesfull</returns>
 public bool Like(Guest guest, Post post)
 {
     return(_context.AddLikeToPost(post, guest.ID));
 }
Ejemplo n.º 51
0
 // POST: api/Guests
 public bool Post([FromBody] Guest g)
 {
     return(mgr.Post(g));
 }
Ejemplo n.º 52
0
 public EventGuestDTO(Guest guest) : base(guest)
 {
     Host = new EventUserDTO(guest.Host);
 }
Ejemplo n.º 53
0
 // POST: api/Guests
 public bool Post([FromBody] Guest guest)
 {
     return(manager.Post(guest));
 }
Ejemplo n.º 54
0
 public GuestPresenter()
 {
     _guest        = new Guest();
     _event        = new Event();
     _eventDetails = new EventDetails();
 }
Ejemplo n.º 55
0
 public void AddGuest(Guest guest)
 {
     guestList.Add(guest);
     //guest.MoveTo(positionList[guestList.IndexOf(guest)]);
     OnGuestArrive?.Invoke(this, EventArgs.Empty);
 }
        /// <summary>
        /// Alisa Roehr
        /// Created: 2019/01/24
        ///
        /// connect to database to edit a guest in the guest table.
        /// </summary>
        ///
        /// <remarks>
        ///
        /// </remarks>
        /// <param name="GuestID">guests unique id number</param>
        /// <param name="MemberID">member ID connected to the guest, either their own member Id or the member Id of the person who created their party.</param>
        /// <param name="GuestTypeID">A Guest Type is the type of guest that is with the Member. Guest Types can be child, spouse, etc.</param>
        /// <param name="FirstName">First name of guest</param>
        /// <param name="LastName">Last name of guest</param>
        /// <param name="PhoneNumber">Phone number of the guest</param>
        /// <param name="Email">guests email</param>
        /// <param name="Minor">is the guest a minor or not</param>
        /// <param name="Active">is the guest a active or not</param>
        /// <param name="ReceiveTexts"></param>
        /// <param name="EmergencyFirstName"></param>
        /// <param name="EmergencyLastName"></param>
        /// <param name="EmergencyPhoneNumber"></param>
        /// <param name="EmergencyRelation"></param>
        ///
        /// <param name="OldMemberID">member ID connected to the guest, either their own member Id or the member Id of the person who created their party.</param>
        /// <param name="OldGuestTypeID">A Guest Type is the type of guest that is with the Member. Guest Types can be child, spouse, etc.</param>
        /// <param name="OldFirstName">First name of guest</param>
        /// <param name="OldLastName">Last name of guest</param>
        /// <param name="OldPhoneNumber">Phone number of the guest</param>
        /// <param name="OldEmail">guests email</param>
        /// <param name="OldMinor">is the guest a minor or not</param>
        /// <param name="OldActive">is the guest a active or not</param>
        /// <param name="OldReceiveTexts"></param>
        /// <param name="OldEmergencyFirstName"></param>
        /// <param name="OldEmergencyLastName"></param>
        /// <param name="OldEmergencyPhoneNumber"></param>
        /// <param name="OldEmergencyRelation"></param>
        ///
        /// <exception cref="SQLException">Update Fails (example of exception tag)</exception>
        /// <returns>Rows edited</returns>
        public int UpdateGuest(Guest newGuest, Guest oldGuest)
        {
            int rows = 0;

            if (!isValid(newGuest))
            {
                return(rows);
            }
            if (!isValid(oldGuest))
            {
                return(rows);
            }

            var conn    = DBConnection.GetDbConnection();
            var cmdText = "sp_update_guest_by_id";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Clear();

            cmd.Parameters.AddWithValue("@GuestID", newGuest.GuestID);

            cmd.Parameters.AddWithValue("@MemberID", newGuest.MemberID);
            cmd.Parameters.AddWithValue("@GuestTypeID", newGuest.GuestTypeID);
            cmd.Parameters.AddWithValue("@FirstName", newGuest.FirstName);
            cmd.Parameters.AddWithValue("@LastName", newGuest.LastName);
            cmd.Parameters.AddWithValue("@PhoneNumber", newGuest.PhoneNumber);
            cmd.Parameters.AddWithValue("@Email", newGuest.Email);
            cmd.Parameters.AddWithValue("@Minor", newGuest.Minor);
            cmd.Parameters.AddWithValue("@Active", newGuest.Active);
            cmd.Parameters.AddWithValue("@ReceiveTexts", newGuest.ReceiveTexts);
            cmd.Parameters.AddWithValue("@EmergencyFirstName", newGuest.EmergencyFirstName);
            cmd.Parameters.AddWithValue("@EmergencyLastName", newGuest.EmergencyLastName);
            cmd.Parameters.AddWithValue("@EmergencyPhoneNumber", newGuest.EmergencyPhoneNumber);
            cmd.Parameters.AddWithValue("@EmergencyRelation", newGuest.EmergencyRelation);
            // cmd.Parameters.AddWithValue("@CheckedIn", newGuest.CheckedIn);

            cmd.Parameters.AddWithValue("@OldMemberID", oldGuest.MemberID);
            cmd.Parameters.AddWithValue("@OldGuestTypeID", oldGuest.GuestTypeID);
            cmd.Parameters.AddWithValue("@OldFirstName", oldGuest.FirstName);
            cmd.Parameters.AddWithValue("@OldLastName", oldGuest.LastName);
            cmd.Parameters.AddWithValue("@OldPhoneNumber", oldGuest.PhoneNumber);
            cmd.Parameters.AddWithValue("@OldEmail", oldGuest.Email);
            cmd.Parameters.AddWithValue("@OldMinor", oldGuest.Minor);
            cmd.Parameters.AddWithValue("@OldActive", oldGuest.Active);
            cmd.Parameters.AddWithValue("@OldReceiveTexts", oldGuest.ReceiveTexts);
            cmd.Parameters.AddWithValue("@OldEmergencyFirstName", oldGuest.EmergencyFirstName);
            cmd.Parameters.AddWithValue("@OldEmergencyLastName", oldGuest.EmergencyLastName);
            cmd.Parameters.AddWithValue("@OldEmergencyPhoneNumber", oldGuest.EmergencyPhoneNumber);
            cmd.Parameters.AddWithValue("@OldEmergencyRelation", oldGuest.EmergencyRelation);
            // cmd.Parameters.AddWithValue("@OldCheckedIn", oldGuest.CheckedIn);

            try
            {
                conn.Open();
                rows = cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(rows);
        }
Ejemplo n.º 57
0
 public static async Task UpdateSingleGuestAsync(Guest newGuest)
 {
 }
        public IActionResult AddReservationC(RoomType type, int idguest, DateTime checkin, DateTime checkout)
        {
            if (ModelState.IsValid)
            {
                var RoomToRentTypeList = (from Room item in _context.Rooms
                                          where item.nubmerbeds == type
                                          select item).ToList();

                Guest GuestToRent = (from Guest item in _context.Guests
                                     where item.GuestID == idguest
                                     select item).SingleOrDefault();
                var RoomTypeNumbers = (from Room n in RoomToRentTypeList
                                       select n.RoomID).ToList();
                var ReservationTypes = (from Reservation n in _context.Reserevations
                                        where RoomTypeNumbers.Contains(n.RoomID)
                                        select n);

                // need db for checkin&checkoutvalues
                // filtering method propsal
                DateTime checkinvalue  = new DateTime();
                DateTime checkoutvalue = new DateTime();
                checkinvalue  = checkin;
                checkoutvalue = checkout;
                int numberOfRoomProposal = (from Reservation m in ReservationTypes
                                            where (checkinvalue < m.check_in &&
                                                   checkoutvalue < m.check_in) ||
                                            (checkinvalue > m.check_out &&
                                             checkoutvalue > m.check_out)
                                            select m.RoomID).FirstOrDefault();
                // lista numerów zajętych w konkretnej dacie
                var numbersOfRoomOccupied = (from Reservation m in ReservationTypes
                                             where (checkinvalue >= m.check_in &&
                                                    checkinvalue <= m.check_out) ||
                                             (checkoutvalue >= m.check_in &&
                                              checkoutvalue <= m.check_out)
                                             select m.RoomID).ToList();
                // lista z wyrzuconymi zajętymi numerami
                var RoomsToRent = (from Room n in RoomToRentTypeList
                                   where !numbersOfRoomOccupied.Contains(n.RoomID)
                                   select n).ToList();

                /*var RoomToRent = (from Room n in RoomToRentTypeList
                 *                where n.RoomID == numberOfRoomProposal
                 *                select n).FirstOrDefault();*/

                var RoomToRent = (from Room n in RoomsToRent
                                  select n).FirstOrDefault();


                if (RoomToRent != null)
                {
                    RoomToRent.is_ocuppied = true;

                    Reservation NewReservation = new Reservation();
                    NewReservation.status    = 0;
                    NewReservation.GuestID   = GuestToRent.GuestID;
                    NewReservation.GuestName = (GuestToRent.name + " " + GuestToRent.surname);
                    NewReservation.RoomID    = RoomToRent.RoomID;
                    NewReservation.check_in  = checkin;
                    NewReservation.check_out = checkout;

                    _context.Reserevations.Add(NewReservation);
                    _context.SaveChanges();
                }
                if (RoomToRent == null)
                {
                    ViewBag.NoFreeRooms = "No rooms available.";
                }
            }
            if (!ModelState.IsValid)
            {
                ViewBag.ValidationText = "Please enter correct check-in and check-out value!";
            }
            var singlereservation = from n in _context.Reserevations
                                    select n;
            var reservationVM = new HotelViewModel
            {
                ReservationList = singlereservation.ToList()
            };

            return(View(reservationVM));
        }
        public ActionResult Register(RegistrationViewModel newUser)
        {
            if (ModelState.IsValid)
            {
                if (_context.Characters.Find(newUser.CharacterUrl) == null)
                {
                    var serializer = new JsonSerializer();

                    HttpWebRequest characterRequest = WebRequest.CreateHttp(newUser.CharacterUrl);

                    characterRequest.UserAgent = "Mozilla / 5.0(Windows NT 6.1; Win64; x64; rv: 47.0) Gecko / 20100101 Firefox / 47.0";

                    HttpWebResponse characterResponse = (HttpWebResponse)characterRequest.GetResponse();

                    if (characterResponse.StatusCode == HttpStatusCode.OK)
                    {
                        using (var data = new StreamReader(characterResponse.GetResponseStream()))
                            using (var jsonReader = new JsonTextReader(data))
                            {
                                var fullCharacter = serializer.Deserialize <FullCharacter>(jsonReader);
                                _context.Characters.Add(fullCharacter.ToModel());
                            }
                    }
                }
                var guest = new Guest()
                {
                    FirstName = newUser.FirstName, LastName = newUser.LastName, AttendanceDate = newUser.AttendanceDate, EmailAddress = newUser.EmailAddress, Guest1 = newUser.Guest1, Attending = (newUser.Attending == "Yes"), CharacterUrl = newUser.CharacterUrl
                };
                _context.Guests.Add(guest);
                _context.SaveChanges();
                if (newUser.Attending == "Yes")
                {
                    var user = new IdentityUser()
                    {
                        UserName = newUser.EmailAddress
                    };
                    var identityResult = _userManager.Create(user, newUser.Password);

                    if (identityResult.Succeeded)
                    {
                        TempData["Guest"] = guest;

                        var authManager = HttpContext.GetOwinContext().Authentication;
                        var ident       = _userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
                        authManager.SignIn(new AuthenticationProperties {
                            IsPersistent = false
                        }, ident);

                        return(RedirectToAction("Create", "Dishes"));
                    }
                    ModelState.AddModelError("", identityResult.Errors.FirstOrDefault());
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            var characters = GetCharacters(271);

            ViewBag.CharacterUrl = new SelectList(characters, "Url", "Name");
            ViewBag.Joke         = GetChuckNorrisJoke();
            return(View(newUser));
        }
Ejemplo n.º 60
0
 public static async Task DeleteSingleGuestAsync(Guest newGuest)
 {
 }