Beispiel #1
0
        public async Task <IActionResult> Register([FromBody] WUser wUser)
        {
            var newUser = new ApplicationUser {
                UserName = wUser.Email,
                Email    = wUser.Email,
                Name     = wUser.Name,
            };
            var userCreationResult = await _userManager
                                     .CreateAsync(newUser, wUser.Password);

            if (userCreationResult.Succeeded)
            {
                //todo not sure if needed
                //await _context.ApplicationUsers.AddAsync(newUser);
                //await _context.SaveChangesAsync();
                return(new ObjectResult(GenerateToken(wUser.Email)));
                //return Ok(newUser);
            }

            foreach (var error in userCreationResult.Errors)
            {
                ModelState.AddModelError(string.Empty, error.Description);
            }

            return(BadRequest(ModelState));
        }
Beispiel #2
0
        private void ButtonClick_AccessEdit(object sender, RoutedEventArgs e)
        {
            WUser DataUser = (sender as Button).DataContext as WUser;

            _UsersEditAccessPage?.ClosePage();
            _UsersEditAccessPage = new UsersEditAccessPage(this, DataUser);
            _UsersEditAccessPage.OpenPage();
        }
        public UserEditPage(MainMenuWindow _MainMenuWindow, WUser User)
        {
            InitializeComponent();
            LoadWindowParent(_MainMenuWindow);
            EventsInitialize();

            this.User        = User;
            this.DataContext = this.User;
        }
Beispiel #4
0
        private void ButtonClick_UserEdit(object sender, RoutedEventArgs e)
        {
            WUser DataUser = (sender as Button).DataContext as WUser;

            _UserEditPage?.ClosePage();
            _UserEditPage = new UserEditPage(_MainMenuWindow, DataUser);
            _UserEditPage.OpenPage();

            _MainMenuWindow.WindowLogic.SetPage(_UserEditPage);
        }
Beispiel #5
0
        public static WUser[] ConvertUser(User[] DbUsers)
        {
            var Users = new WUser[DbUsers.Length];

            for (int i = 0; i < DbUsers.Length; i++)
            {
                Users[i] = ConvertUser(DbUsers[i]);
            }

            return(Users);
        }
Beispiel #6
0
        public IActionResult Put(string id, [FromBody] WUser p)
        {
            var recId = new ObjectId(id);
            var user  = objds.GetUser(recId);

            if (user == null)
            {
                return(NotFound());
            }

            objds.Update(recId, p);
            return(new OkResult());
        }
Beispiel #7
0
        public UsersEditAccessPage(UsersMainPage _UsersMainPage, WUser DataUser)
        {
            InitializeComponent();
            LoadParentWindows(_UsersMainPage);
            EventsInitialize();
            NetworkEvents();

            this.DataUser = DataUser;

            DataGrid_Access.ItemsSource = AccessCollecton;
            DataGrid_Access.IsEnabled   = false;

            Sender.SendToServer("Access.GetAll");
        }
Beispiel #8
0
        public async Task <IActionResult> JWTlogin([FromBody] WUser wUser)
        {
            var user = await _userManager.FindByEmailAsync(wUser.Email);

            if (user == null)
            {
                ModelState.AddModelError(string.Empty, "Invalid login");
                return(BadRequest(ModelState));
            }
            var passwordSignInResult = await _signInManager
                                       .CheckPasswordSignInAsync(user, wUser.Password, false);

            if (passwordSignInResult.Succeeded)
            {
                return(new ObjectResult(GenerateToken(wUser.Email)));
            }
            return(BadRequest("Invalid login"));
        }
Beispiel #9
0
        public static WTeamUserCompilation ConvertTeamUserCompilation(User[] DbUsers, TeamUser[] DbTeamUsers)
        {
            var Users = new WUser[DbUsers.Length];

            for (int i = 0; i < DbUsers.Length; i++)
            {
                Users[i] = ConvertUser(DbUsers[i]);
            }

            var TeamUsers = new WTeamUser[DbTeamUsers.Length];

            for (int i = 0; i < DbTeamUsers.Length; i++)
            {
                TeamUsers[i] = ConvertTeamUser(DbTeamUsers[i]);
            }

            return(new WTeamUserCompilation
            {
                TeamUsers = TeamUsers,
                Users = Users
            });
        }
Beispiel #10
0
        private void ButtonClick_UserDelete(object sender, RoutedEventArgs e)
        {
            new ConfirmWindow("Предупреждение", "Вы уверены что хотите удалить элемент?", delegate()
            {
                WUser DataUser = (sender as Button).DataContext as WUser;

                if (Sender.SendToServer("Users.Delete", DataUser.Id))
                {
                    DataGrid_Users.IsEnabled = false;

                    ServerResponseDelay = CustomTimer.Create(delegate(object sender, EventArgs e)
                    {
                        ServerResponseDelay = null;

                        new AlertWindow("Ошибка", "Время ожидания ответа от сервера истекло.",
                                        () => DataGrid_Users.IsEnabled = true);
                    }, new TimeSpan(0, 0, 5), true);
                }
                else
                {
                    new AlertWindow("Ошибка", AlertWindow.AlertCode.SendToServer);
                }
            });
        }
Beispiel #11
0
 public IActionResult Post([FromBody] WUser p)
 {
     objds.Create(p);
     return(new OkObjectResult(p));
 }