Пример #1
0
 public static ApartmentEntity ToEntity(this ApartmentInfo data)
 {
     if (data == null)
     {
         return(null);
     }
     return(new ApartmentEntity
     {
         ExternalId = data.ExternalId,
         Lat = data.Location.Lat,
         Lng = data.Location.Lng,
         Price = data.Price,
         Url = data.Url,
         ApartmentNumber = data.ApartmentNumber,
         Floor = data.Floor,
         FloorsCount = data.FloorsCount,
         RoomsCount = data.RoomsCount,
         Area = data.Area,
         Title = data.Title,
         Address = data.Address,
         PublishingDate = data.PublishingDateUtc,
         DisappearedDate = data.DisappearedDate,
         ImageUrlsJson = JsonConvert.SerializeObject(data.ImageUrls)
     });
 }
        /// <summary>
        /// Creates new instance of AddReservationReviewForm.
        /// </summary>
        /// <param name="person">Person's data to display.</param>
        /// <param name="apartment">Apartment data to display.</param>
        /// <param name="reservation">Reservation details to display.</param>
        public AddReservationReviewForm(PersonInfo person, ApartmentInfo apartment, ReservationInfo reservation)
        {
            InitializeComponent();

            Person      = person;
            Apartment   = apartment;
            Reservation = reservation;

            InitializeLabelsText();
        }
Пример #3
0
        /// <summary>
        /// Saves apartments to DB from <see cref="SampleApartmentsRelativePath"/>.
        /// </summary>
        /// <param name="currentLine">Current line being read.</param>
        private void GenerateApartment(string currentLine)
        {
            var segments = currentLine.Split(';');

            if (segments.Length != 4)
            {
                throw new InvalidDataException(nameof(segments));
            }

            var apartment = new ApartmentInfo(int.Parse(segments[0]), int.Parse(segments[1]), int.Parse(segments[2]), int.Parse(segments[3]));

            Apartments.Add(apartment);
        }
Пример #4
0
 public static ApartmentDto ToDto(this ApartmentInfo apartment)
 {
     return(new ApartmentDto
     {
         ApartmentId = apartment.ApartmentId,
         Area = apartment.Area,
         BuildingId = apartment.BuildingId,
         Number = apartment.Number,
         OccupantCount = apartment.OwnerTenants
                         .Where(c => c.To == null)
                         .Sum(c => c.OccupantCount)
     });
 }
        /// <summary>
        /// Creates a new instance of AddReservationRoomDetailsForm.
        /// </summary>
        /// <param name="person">Person's data to display.</param>
        /// <param name="apartment">Apartment data to display.</param>
        /// <param name="reservation">Reservation details to display.</param>
        public AddReservationRoomDetailsForm(PersonInfo person = null, ApartmentInfo apartment = null, ReservationInfo reservation = null)
        {
            InitializeComponent();

            InitializeLabelsText(person, apartment, reservation);

            FromDateTimePicker_ValueChanged(null, null);

            UpdateNumberOfAvailableApartments();

            proceedButton.Enabled = false;

            infoLabel.Text = string.Empty;
        }
Пример #6
0
        private void SelectApartmentComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectedApartment = Apartments.ElementAt(selectApartmentComboBox.SelectedIndex);

            roomNumberTextBox.Text    = SelectedApartment.Number.ToString();
            roomNumberTextBox.Enabled = true;

            priceTextBox.Text    = SelectedApartment.Price.ToString();
            priceTextBox.Enabled = true;

            capacityComboBox.SelectedIndex = SelectedApartment.Capacity - 1;
            capacityComboBox.Enabled       = true;

            doubleBedsComboBox.SelectedIndex = SelectedApartment.DoubleBeds;
            doubleBedsComboBox.Enabled       = true;
        }
Пример #7
0
        public void Apartment_Map_To_ApartmentDto()
        {
            ApartmentInfo otdto = new ApartmentInfo
            {
                BuildingId  = 1,
                Area        = 29,
                ApartmentId = 4,
                Number      = 34,
            };
            var  ow    = otdto;
            bool check = true;

            if (otdto.Number == ow.Number && otdto.BuildingId == ow.BuildingId &&
                otdto.ApartmentId == ow.ApartmentId && ow.Area == otdto.Area)
            {
                check = true;
            }
            Assert.IsTrue(check);
        }
Пример #8
0
        public void Apartment_Map_To_Entry()
        {
            ApartmentDto otdto = new ApartmentDto
            {
                BuildingId  = 1,
                Area        = 29,
                ApartmentId = 4,
                Number      = 34
            };
            ApartmentInfo ow = otdto.ToEntry();

            bool check = false;

            if (otdto.Number == ow.Number && otdto.BuildingId == ow.BuildingId &&
                otdto.ApartmentId == ow.ApartmentId && ow.Area == otdto.Area)
            {
                check = true;
            }
            Assert.IsTrue(check);
        }
        private void AvailableApartmentsComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectedApartment = AvailableApartments.ElementAt(availableApartmentsComboBox.SelectedIndex);

            actualRoomNumberLabel.Text = SelectedApartment.Number.ToString();

            proceedButton.Enabled = true;

            var reservation = new ReservationInfo()
            {
                From        = fromDateTimePicker.Value,
                To          = toDateTimePicker.Value,
                Person      = Person,
                PersonId    = Person.PersonId,
                Apartment   = SelectedApartment,
                ApartmentId = SelectedApartment.ApartmentId
            };

            Reservation = reservation;

            CheckApartmentAvailability();
        }
        /// <summary>
        /// Initializes the labels' text from supplied details.
        /// </summary>
        /// <param name="person">Person's data to display.</param>
        /// <param name="apartment">Apartment data to display.</param>
        /// <param name="reservation">Reservation details to display.</param>
        private void InitializeLabelsText(PersonInfo person, ApartmentInfo apartment, ReservationInfo reservation)
        {
            if (person != null)
            {
                Person = person;

                nameLabel.Text        = person.FirstName + @" " + person.LastName;
                emailLabel.Text       = person.Email;
                dateOfBirthLabel.Text = person.DateOfBirth.ToShortDateString();
            }

            if (apartment != null)
            {
                minimalCapacityNumericUpDown.Value = apartment.Capacity;
                doubleBedsNumericUpDown.Value      = apartment.DoubleBeds;
            }

            if (reservation != null)
            {
                fromDateTimePicker.Value = reservation.From;
                toDateTimePicker.Value   = reservation.To;
            }
        }
 protected void Update_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         ApartmentInfo obj = new ApartmentInfo();
         //obj.Id = Id;
         //obj.Name = txtName.Text;
         //obj.Logo = txtLogo.Text;
         //obj.Ord = txtOrd.Text;
         //obj.Lang = Lang;
         if (Insert == true)
         {
             ApartmentService.ApartmentInfo_Insert(obj);
         }
         else
         {
             ApartmentService.ApartmentInfo_Update(obj);
         }
         BindGrid();
         pnView.Visible   = true;
         pnUpdate.Visible = false;
         Insert           = false;
     }
 }
 public static bool IsNewest(this ApartmentInfo info) => DateTime.UtcNow - info.CreatedAtUtc < NewestApartmentsTimeout;
        private void SelectedApartmentComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            SelectedApartment = Apartments.ElementAt(selectedApartmentComboBox.SelectedIndex);

            deleteButton.Enabled = true;
        }
 public ApartmentDataViewModel(ApartmentInfo apartment)
 {
     _apartment = apartment ?? throw new ArgumentNullException(nameof(apartment));
     IsNewest   = apartment.IsNewest();
     ImageUrls  = new ObservableCollection <string>(_apartment.ImageUrls);
 }
Пример #15
0
 public static bool ApartmentInfo_Update(ApartmentInfo data)
 {
     return(db.ApartmentInfo_Update(data));
 }
Пример #16
0
 public static bool ApartmentInfo_Insert(ApartmentInfo data)
 {
     return(db.ApartmentInfo_Insert(data));
 }
 /// <summary>
 /// Returns all reservations for a specified apartment.
 /// </summary>
 /// <param name="apartment">Apartment the reservations of which to retrieve.</param>
 public static IEnumerable <ReservationInfo> GetAllReservationsForApartment(this ApartmentInfo apartment)
 {
     return(GuestBook.Context.Reservations.Where(reservation => reservation.ApartmentId == apartment.ApartmentId));
 }
Пример #18
0
 public static Task <Message> SendApartmentMessages(this ITelegramBotClient botClient, string chatId, ApartmentInfo apartment)
 {
     return(botClient.SendPhotoAsync(
                chatId: new ChatId(chatId),
                photo: apartment.ImageRef,
                caption: $"<b>Rua</b>: {apartment.Rua},\n" +
                $"<b>Bairro</b>: {apartment.Bairro}, {apartment.Cidade},\n" +
                $"<b>Área</b>: {apartment.Area}m²,\n" +
                $"<b>Aluguel</b>: R$ {apartment.Aluguel.ToString("F", new System.Globalization.CultureInfo("pt-BR"))},\n" +
                $"<b>Valor Total</b>: R$ {apartment.Total.ToString("F", new System.Globalization.CultureInfo("pt-BR"))},\n" +
                $"<b>Link</b>: <a>{apartment.Href}</a>",
                parseMode: ParseMode.Html
                ));
 }
 public static bool IsOld(this ApartmentInfo info) => DateTime.UtcNow - info.PublishingDateUtc > OldApartmentsTimeout;
Пример #20
0
        /// <summary>
        /// Validates data from the input boxes.
        /// </summary>
        private void ValidateData()
        {
            var apartments = ApartmentProvider.GetAllApartments().ToList();

            if (!int.TryParse(roomNumberTextBox.Text, out var roomNumber))
            {
                MessageBox.Show(@"Please enter a valid room number");

                return;
            }

            if (apartments.Any(apartment => apartment.Number.Equals(roomNumber)))
            {
                MessageBox.Show(@"An apartment with this number already exists. Please enter a different number.");

                return;
            }

            if (!int.TryParse(priceTextBox.Text, out var price))
            {
                MessageBox.Show(@"Please enter a valid price");

                return;
            }

            if (price <= 0)
            {
                MessageBox.Show(@"Please enter a correct price.");

                return;
            }

            if (capacityComboBox.SelectedIndex < 0)
            {
                MessageBox.Show(@"Please select capacity.");

                return;
            }

            if (doubleBedsComboBox.SelectedIndex < 0)
            {
                MessageBox.Show(@"Please select the number of double beds.");

                return;
            }

            if (int.Parse(doubleBedsComboBox.SelectedItem.ToString()) * 2 > int.Parse(capacityComboBox.SelectedItem.ToString()))
            {
                MessageBox.Show(@"The capacity is not enough to accommodate this number of double beds.");

                return;
            }

            var newApartment = new ApartmentInfo(int.Parse(roomNumberTextBox.Text), int.Parse(priceTextBox.Text),
                                                 int.Parse(capacityComboBox.SelectedItem.ToString()),
                                                 int.Parse(doubleBedsComboBox.SelectedItem.ToString()));

            ApartmentProvider.SetApartment(newApartment);

            MessageBox.Show(@"Apartment successfully created.");

            Close();
        }
        private void ApartmentsComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Apartment = Apartments[apartmentsComboBox.SelectedIndex];

            CheckApartmentAvailability();
        }
Пример #22
0
 public static Task <Message> SendApartmentMessages(this ITelegramBotClient botClient, string chatId, ApartmentInfo apartment)
 {
     return(botClient.SendPhotoAsync(
                chatId: new ChatId(chatId),
                photo: apartment.ImageRef,
                caption: $"<b>Rua</b>: {apartment.Rua},\n" +
                $"<b>Bairro</b>: {apartment.Bairro},\n" +
                $"<b>Área</b>: {apartment.Area}m²,\n" +
                $"<b>Aluguel</b>: {apartment.Aluguel.Replace("Aluguel ", "")},\n" +
                $"<b>Valor Total</b>: {apartment.Total.Replace("Total ", "")},\n" +
                $"<b>Link</b>: <a>{apartment.Href}</a>",
                parseMode: ParseMode.Html
                ));
 }