Esempio n. 1
0
        public async void Create()
        {
            try
            {
                Acr.UserDialogs.UserDialogs.Instance.ShowLoading(AppResource.alertLoading);

                if (pckLocationType.SelectedIndex < 1)
                {
                    await DisplayAlert(AppResource.alertAlert, AppResource.alertSelectedLocation, AppResource.textOk);

                    return;
                }
                if (pckLocationMenuType.SelectedIndex < 1)
                {
                    await DisplayAlert(MocoApp.Resources.AppResource.alertAlert, AppResource.alertSelectedLocationMenu, AppResource.textOk);

                    return;
                }

                Location _location = new Location();
                if (_imageStream != null)
                {
                    //faz upload da imagem
                    ApiService service = new ApiService();
                    _location.ImageUri = await service.UploadImage(_imageStream);
                }

                _location.Name           = txtName.Text;
                _location.IsDisabled     = !swtActive.IsToggled;
                _location.CompanyId      = Helpers.Settings.DisplayUserCompany;
                _location.IsRoom         = swtActive.IsToggled;
                _location.LocationType   = (LocationType)pckLocationType.SelectedIndex;
                _location.Prefix         = txtPrefixo.Text;
                _location.OrderingNumber = Convert.ToInt32(txtPosition.Text);
                _location.MenuType       = (EMenuType)pckLocationMenuType.SelectedIndex;
                string result = await _companyService.CreateLocation(_location);

                Acr.UserDialogs.UserDialogs.Instance.Toast(AppResource.lblItemCreatedSucess);
                await App.AppCurrent.NavigationService.GoBack();
            }
            catch (Exception ex)
            {
                DisplayAlert(AppResource.alertAlert, ex.Message, AppResource.textOk);
            }
            finally
            {
                Acr.UserDialogs.UserDialogs.Instance.HideLoading();
            }
        }