示例#1
0
        public async Task Post([FromBody] Profile value)
        {
            try
            {
                await _profileService.AddProfile(value);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);

                throw ex;
            }
        }
        public override bool Commit()
        {
            var profileType = SettingsProfileType.SingleMonitor;

            if (IsSimPitSetup.Value)
            {
                profileType = SettingsProfileType.SimPit;
            }

            if (IsVirtualRealitySetup.Value)
            {
                profileType = SettingsProfileType.VirtualReality;
            }

            if (IsHeliosSetup.Value)
            {
                profileType = SettingsProfileType.Helios;
            }

            var profile = new Profile {
                Name = ProfileName.Value, ProfileType = profileType
            };

            _profileSettingsService.AddProfile(profile);
            _profileSettingsService.SelectedProfileName = profile.Name;
            _profileSettingsService.SetValue(ProfileCategories.GameOptions, "options.VR.enabled", IsVirtualRealitySetup.Value);

            var primaryScreen = Screen.PrimaryScreen;

            //switch (profileType)
            //{
            //    case SettingsProfileType.SingleMonitor:
            //        _profileSettingsService.SetValue(Viewport.Viewports, SettingsKeys.DeviceViewportsDisplays, new []{primaryScreen.DeviceName});
            //        break;
            //    case SettingsProfileType.Helios:
            //    case SettingsProfileType.SimPit:
            //        Controller.Steps.Add(new SelectGameViewportScreensStepViewModel(Container));
            //        Controller.Steps.Add(new SelectUIViewportScreensStepViewModel(Container));
            //        Controller.Steps.Add(new SelectDeviceViewportScreensStepViewModel(Container));
            //        break;
            //    case SettingsProfileType.VirtualReality:
            //        _profileSettingsService.SetValue(ProfileCategories.Viewports, SettingsKeys.DeviceViewportsDisplays, new[] { primaryScreen.DeviceName });
            //        break;
            //    default:
            //        throw new ArgumentOutOfRangeException();
            //}

            return(base.Commit());
        }
        public AddEditProfileViewModel(INavigationService navigationService, IProfileService profileService) :
            base(navigationService)
        {
            _profile = new Profile()
            {
                UserId = User.Current.UserId
            };
            AddSaveCommand = new DelegateCommand(() =>
            {
                if (NickName == "" || Name == "")
                {
                    UserDialogs.Instance.Alert(TextResources.FiledsNandNNmustbefilled, TextResources.Error, TextResources.Ok);
                    return;
                }

                if (_IsEdit)
                {
                    profileService.UpdateProfile(_profile);
                }
                else
                {
                    profileService.AddProfile(_profile);
                }
                navigationService.GoBackAsync();
            });

            SelectImageCommand = new DelegateCommand(() =>
            {
                UserDialogs.Instance.ActionSheet(new ActionSheetConfig()
                {
                    Message = TextResources.ChooseAction,
                    Options = new List <ActionSheetOption>()
                    {
                        new ActionSheetOption(TextResources.PickAtGallery, async() => {
                            var result       = await FilePicker.PickAsync();
                            ImageDestination = result?.FullPath ?? ImageDestination;
                        }, "ic_collections_3x.png"),

                        new ActionSheetOption(TextResources.TakeAPhotoWithCamera, async() => {
                            var result       = await MediaPicker.CapturePhotoAsync();
                            ImageDestination = result?.FullPath ?? ImageDestination;
                        }, "ic_camera_alt3x.png")
                    },
                    Cancel = new ActionSheetOption(TextResources.Cancel)
                });
            });
        }
示例#4
0
        public IHttpActionResult AddMyProfile([FromBody] ProfilePostModel profile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ProfileDTO profileDTO = new ProfileDTO
            {
                Name        = profile.Name,
                Description = profile.Description,
                ImageFileId = profile.ImageFileId,
                BirthDate   = profile.BirthDate,
                UserId      = User.Identity.GetUserId(),
            };
            int id = _profileService.AddProfile(profileDTO);

            return(Ok(id));
        }
示例#5
0
        public async Task <ActionResult <FullProfile> > CreateProfile(CreateProfileRequest request)
        {
            if (!request.IsValid(out var error))
            {
                return(BadRequest(error));
            }

            try
            {
                Profile profile = request.ToProfile();
                await _profileService.AddProfile(profile);

                return(CreatedAtAction(nameof(GetProfile), request.Username,
                                       await _profileService.GetFullProfile(profile)));
            }
            catch (DuplicateProfileException e)
            {
                return(Conflict(e.Message));
            }
            catch (EmployerNotFoundException e)
            {
                return(NotFound(e.Message));
            }
        }
        public async Task <IActionResult> Post([FromBody] UserProfile userProfile)
        {
            await _profileService.AddProfile(userProfile);

            return(CreatedAtAction(nameof(Get), new { username = userProfile.Username }, userProfile));
        }
        protected override void DrawInternal()
        {
            Caption = AddOrEdit == ProfileAddOrEdit.Add
                ? $"{nameof(ProfileAddOrEdit.Add)} Profile"
                : $"{nameof(ProfileAddOrEdit.Edit)} Profile";

            var profileName = AddOrEdit == ProfileAddOrEdit.Edit
                ? SelectedProfile?.Name ?? string.Empty
                : _profileName;
            var profileServerName = AddOrEdit == ProfileAddOrEdit.Edit
                ? SelectedProfile?.HostName ?? string.Empty
                : _profileServerName;
            var profileServerPort = AddOrEdit == ProfileAddOrEdit.Edit
                ? SelectedProfile?.HostPort ?? 0
                : _profileServerPort;
            var profileAccountName = AddOrEdit == ProfileAddOrEdit.Edit
                ? SelectedProfile?.UserName ?? string.Empty
                : _profileAccountName;
            var profileAccountPasswordHash = AddOrEdit == ProfileAddOrEdit.Edit
                ? SelectedProfile?.UserPassword ?? string.Empty
                : _profileAccountPassword;

            if (ImGui.InputText("Name", ref profileName, 256))
            {
                _profileName = profileName;
            }

            ImGui.Separator();

            if (ImGui.InputText("Server", ref profileServerName, 32))
            {
                _profileServerName = profileServerName;
            }

            if (ImGui.InputInt("Port", ref profileServerPort))
            {
                _profileServerPort = profileServerPort;
            }

            ImGui.Separator();

            if (ImGui.InputText("Account Name", ref profileAccountName, 128))
            {
                _profileAccountName = profileAccountName;
            }

            if (ImGui.InputText("Account Password", ref profileAccountPasswordHash, 128))
            {
                _profileAccountPassword = profileAccountPasswordHash;
            }

            ImGui.Separator();

            if (ImGui.Button(AddOrEdit == ProfileAddOrEdit.Add ? "Add" : "Update"))
            {
                if (AddOrEdit == ProfileAddOrEdit.Add)
                {
                    var profile = new Profile
                    {
                        Name         = _profileName,
                        HostName     = _profileServerName,
                        HostPort     = _profileServerPort,
                        UserName     = _profileAccountName,
                        UserPassword = _profileAccountPassword
                    };
                    _profileService.AddProfile(profile);
                }
                else if (AddOrEdit == ProfileAddOrEdit.Edit)
                {
                    SelectedProfile !.Name       = _profileName;
                    SelectedProfile.HostName     = _profileServerName;
                    SelectedProfile.HostPort     = _profileServerPort;
                    SelectedProfile.UserName     = _profileAccountName;
                    SelectedProfile.UserPassword = _profileAccountPassword;

                    _profileService.Update(SelectedProfile);
                }
            }

            ImGui.SameLine();
            if (ImGui.Button("Close"))
            {
                Hide();
            }
        }