Exemplo n.º 1
0
        public async Task Submit()
        {
            try
            {
                var addressRequest = new AddressUpsertRequest
                {
                    AdditionalAddress = _additional,
                    City      = _city,
                    CountryId = _selectedCountry.CountryId,
                    Street    = _street,
                    ZipCode   = _zipCode
                };

                Address address;

                if (RequestId != null)
                {
                    address = await _addressService.Update <Address>((int)AddressId, addressRequest);

                    var req = new RequestUpdateRequest
                    {
                        AdditionalInformation = _additionalInformation,
                        Date                    = _dateValue,
                        Price                   = _price,
                        Rooms                   = int.Parse(_rooms),
                        TotalWeightApprox       = int.Parse(_totalWeightApprox),
                        StatusId                = (int)Models.Status.Pending,
                        TransportDistanceApprox = int.Parse(_transportDistanceApprox)
                    };
                    var result = await _requestService.Update <Request>((int)RequestId, req);

                    await Application.Current.MainPage.DisplayAlert(Constants.RequestUpdated, Constants.RequestUpdatedMessage, Constants.OK);
                }
                else
                {
                    address = await _addressService.Insert <Address>(addressRequest);

                    int clientId = Int32.Parse(JWTService.DecodeJWT());
                    var request  = new RequestInsertRequest
                    {
                        AdditionalInformation = _additionalInformation,
                        Created                 = DateTime.Now,
                        Date                    = _dateValue,
                        Price                   = _price,
                        Rooms                   = int.Parse(_rooms),
                        TotalWeightApprox       = int.Parse(_totalWeightApprox),
                        ClientId                = clientId,
                        StatusId                = (int)Models.Status.Pending,
                        DeliveryAddress         = address.AddressId,
                        TransportDistanceApprox = int.Parse(_transportDistanceApprox)
                    };
                    var result = await _requestService.Insert <Request>(request);

                    await Application.Current.MainPage.DisplayAlert(Constants.RequestCreated, Constants.RequestCreatedMessage, Constants.OK);
                }
                ClearForm();
            }
            catch
            {}
        }
Exemplo n.º 2
0
        public async Task Submit()
        {
            if (!IsValid())
            {
                return;
            }

            var request = new AddressUpsertRequest
            {
                AdditionalAddress = AdditionalAddress,
                City      = City,
                CountryId = SelectedCountry.CountryId,
                Street    = Street,
                ZipCode   = ZipCode
            };

            try
            {
                await _addressService.Update <Address>(AddressId, request);

                ShowMessage = true;
            }
            catch
            {}
        }
Exemplo n.º 3
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                if (_editMode)
                {
                    var addressRequest = new AddressUpsertRequest
                    {
                        AdditionalAddress = txtAdditional.Text,
                        City    = txtCity.Text,
                        Street  = txtStreet.Text,
                        ZipCode = txtZipCode.Text
                    };

                    var selectedCountry = cbCountry.SelectedValue;

                    if (int.TryParse(selectedCountry.ToString(), out int vrstaId))
                    {
                        addressRequest.CountryId = vrstaId;
                    }

                    await _addressService.Update <Address>(_address.AddressId, addressRequest);

                    var newRequest = new UserUpdateRequest
                    {
                        Company     = txtCompany.Text,
                        Email       = txtEmail.Text,
                        PhoneNumber = txtPhoneNumber.Text
                    };

                    if (_imageChanged)
                    {
                        newRequest.Image = Helper.ImageToByte(pbImage.Image);
                    }

                    try
                    {
                        await _authService.Update(_user.Id, newRequest);

                        MessageBox.Show("User successfully updated", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        foreach (Control control in this.Controls)
                        {
                            Helper.ClearFormControls(control);
                        }
                    }
                    catch (Exception) {}
                }
                else
                {
                    request.Company           = txtCompany.Text;
                    request.Email             = txtEmail.Text;
                    request.Street            = txtStreet.Text;
                    request.City              = txtCity.Text;
                    request.ZipCode           = txtZipCode.Text;
                    request.AdditionalAddress = txtAdditional.Text;
                    request.RoleId            = 3;
                    request.PhoneNumber       = txtPhoneNumber.Text;

                    var selectedCountry = cbCountry.SelectedValue;

                    if (int.TryParse(selectedCountry.ToString(), out int vrstaId))
                    {
                        request.CountryId = vrstaId;
                    }

                    request.Password        = txtPassword.Text;
                    request.ConfirmPassword = txtConfirmPassword.Text;

                    try
                    {
                        await _authService.Register(request);

                        MessageBox.Show("Supplier successfully registred", "Registration", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        foreach (Control control in this.Controls)
                        {
                            Helper.ClearFormControls(control);
                        }
                    }
                    catch (Exception) { }
                }
            }
        }
Exemplo n.º 4
0
        public async Task <ActionResult <Address> > Upsert(AddressUpsertRequest request)
        {
            var _result = await _mediator.Send(request);

            return(CreatedAtRoute("GetAddress", new { id = _result.Id.ToString() }, _result));
        }