public async Task <bool> AddNewApplicationForUserAsync(IdentityUser user, AddAppModel model) { var app = new Application { UserId = user.Id, AppId = Guid.NewGuid(), AppName = model.AppName, Variables = new List <Variable>() }; _context.Applications.Add(app); var success = await _context.SaveChangesAsync(); return(success == 1); }
void setBinding() { PikerLsItem = PickerLs.SelectedIndex; PikerTypeItem = PickerType.SelectedIndex; try { BindingContext = null; BindingContext = new AddAppModel() { AllAcc = Settings.Person.Accounts, AllType = Settings.TypeApp, hex = (Color)Application.Current.Resources["MainColor"], SelectedAcc = Settings.Person.Accounts[PikerLsItem], SelectedType = Settings.TypeApp[PikerTypeItem], Files = files }; } catch (Exception ex) { // ignored } }
public async Task <IActionResult> AddApp(AddAppModel appModel) { if (!ModelState.IsValid) { return(BadRequest()); } var currentUser = await _userManager.GetUserAsync(User); if (currentUser == null) { return(Challenge()); } var success = await _appService.AddNewApplicationForUserAsync(currentUser, appModel); if (!success) { return(BadRequest()); } return(RedirectToAction("List")); }
public NewAppPage() { InitializeComponent(); Analytics.TrackEvent("Создание заявки"); switch (Device.RuntimePlatform) { case Device.iOS: int statusBarHeight = DependencyService.Get <IStatusBar>().GetHeight(); Pancake.Padding = new Thickness(0, statusBarHeight, 0, 0); break; default: break; } NavigationPage.SetHasNavigationBar(this, false); var profile = new TapGestureRecognizer(); profile.Tapped += async(s, e) => { if (Navigation.NavigationStack.FirstOrDefault(x => x is ProfilePage) == null) { await Navigation.PushAsync(new ProfilePage()); } }; IconViewProfile.GestureRecognizers.Add(profile); var backClick = new TapGestureRecognizer(); backClick.Tapped += async(s, e) => { ClosePage(); }; BackStackLayout.GestureRecognizers.Add(backClick); var techSend = new TapGestureRecognizer(); techSend.Tapped += async(s, e) => { await Navigation.PushAsync(new Tech.AppPage()); }; LabelTech.GestureRecognizers.Add(techSend); var pickLs = new TapGestureRecognizer(); pickLs.Tapped += async(s, e) => { Device.BeginInvokeOnMainThread(() => { PickerLs.Focus(); }); }; StackLayoutLs.GestureRecognizers.Add(pickLs); var pickType = new TapGestureRecognizer(); pickType.Tapped += async(s, e) => { Device.BeginInvokeOnMainThread(() => { PickerType.Focus(); }); }; StackLayoutType.GestureRecognizers.Add(pickType); var call = new TapGestureRecognizer(); call.Tapped += async(s, e) => { if (Settings.Person.Phone != null) { IPhoneCallTask phoneDialer; phoneDialer = CrossMessaging.Current.PhoneDialer; if (phoneDialer.CanMakePhoneCall && !string.IsNullOrWhiteSpace(Settings.Person.companyPhone)) { phoneDialer.MakePhoneCall(System.Text.RegularExpressions.Regex.Replace(Settings.Person.companyPhone, "[^+0-9]", "")); } } }; var addFile = new TapGestureRecognizer(); addFile.Tapped += async(s, e) => { AddFile(); }; StackLayoutAddFile.GestureRecognizers.Add(addFile); SetText(); files = new ObservableCollection <FileData>(); #if DEBUG _appModel = new AddAppModel() { AllAcc = Settings.Person.Accounts, AllType = Settings.TypeApp, AllKindPass = new List <string> { AppResources.PassMan, AppResources.PassMotorcycle, AppResources.PassCar, AppResources.PassGazele, AppResources.PassCargo }, AllBrand = new List <string>() { "Suzuki", "Kavasaki", "Lada", "Opel", "Volkswagen", "Запорожец" }, /*Settings.BrandCar,*/ hex = (Color)Application.Current.Resources["MainColor"], SelectedAcc = Settings.Person.Accounts[0], SelectedType = Settings.TypeApp[0], Files = files }; #else _appModel = new AddAppModel() { AllAcc = Settings.Person.Accounts, AllType = Settings.TypeApp, AllKindPass = new List <string> { AppResources.PassMan, AppResources.PassMotorcycle, AppResources.PassCar, AppResources.PassGazele, AppResources.PassCargo }, AllBrand = Settings.BrandCar, hex = (Color)Application.Current.Resources["MainColor"], SelectedAcc = Settings.Person.Accounts[0], SelectedType = Settings.TypeApp[0], Files = files }; #endif BindingContext = _appModel; ListViewFiles.Effects.Add(Effect.Resolve("MyEffects.ListViewHighlightEffect")); var passTypeEntryTGR = new TapGestureRecognizer(); passTypeEntryTGR.Tapped += async(s, e) => { if (!PassTypesList.IsVisible) { PassTypesList.IsVisible = true; } }; PassType.GestureRecognizers.Add(call); MessagingCenter.Subscribe <Object, string>(this, "SetVisibleLayout", (sender, name) => { if (name.Contains("пропуск")) { SetPassApp(); EntryMess.Text = AppResources.NamePassApp; isPassAPP = true; } else { SetDefaultApp(); EntryMess.Text = ""; isPassAPP = false; } }); }