Beispiel #1
0
        private bool SendData(out Parcel addedParcel)
        {
            int?senderApartment, recieverApartment;
            int senderAp, recieverAp;

            if (int.TryParse(senderApartmentNumberTextBox.Text, out senderAp))
            {
                senderApartment = senderAp;
            }
            else
            {
                senderApartment = null;
            }

            if (int.TryParse(recieverApartmentNumberTextBox.Text, out recieverAp))
            {
                recieverApartment = senderAp;
            }
            else
            {
                recieverApartment = null;
            }

            int?storePlace = _employmentController.GetEmploymentById(_employeeController.GetLoggedEmployee().Id).StorePlaceId;

            Parcel parcelToAdd = new Parcel
            {
                SenderData = new PersonalData
                {
                    FirstName       = senderFirstNameTextBox.Text,
                    LastName        = senderLastNameTextBox.Text,
                    PhoneNumber     = senderPhoneNumberTextBox.Text,
                    PersonalAddress = new Address
                    {
                        City            = senderCityTextBox.Text,
                        PostCode        = senderPostalCodeTextBox.Text,
                        Street          = senderStreetTextBox.Text,
                        HomeNumber      = senderHouseNumberTextBox.Text,
                        ApartmentNumber = senderApartment
                    }
                },
                ReceiverData = new PersonalData
                {
                    FirstName       = recieverFirstNameTextBox.Text,
                    LastName        = recieverLastNameTextBox.Text,
                    PhoneNumber     = recieverPhoneNumberTextBox.Text,
                    PersonalAddress = new Address
                    {
                        City            = recieverCityTextBox.Text,
                        PostCode        = recieverPostalCodeTextBox.Text,
                        Street          = recieverStreetTextBox.Text,
                        HomeNumber      = recieverHouseNumberTextBox.Text,
                        ApartmentNumber = recieverApartment
                    }
                },
                ParcelHeight = float.Parse(parcelDimensionsXTextBox.Text),
                ParcelWidth  = float.Parse(parcelDimensionsYTextBox.Text),
                ParcelLength = float.Parse(parcelDimensionsZTextBox.Text),
                ParcelType   = parcelType,
                ParcelWeight = float.Parse(parcelWeightTextBox.Text),
                Priority     = parcelPriorityComboBox.SelectedIndex,
                StorePlaceId = storePlace,
            };

            addedParcel = parcelToAdd;
            return(_parcelController.PostParcel(parcelToAdd));
        }