public IActionResult AcceptRequest([FromBody] AcceptRequestViewModel vm)
        {
            var user = GetUser();
            if (user == null)
            {
                return new UnauthorizedResult();
            }

            var request = db.RouteRequest.FirstOrDefault(rr => rr.RequestId == vm.RequestId);
            request.Status = 1;
            db.Entry(request).State = EntityState.Modified;
            db.SaveChanges();

            return Json(new { message = "Success" });
        }
    private void PopulateDb(PickMeAppContext context)
    {
      this.CreateTestUsers();
      context.Groups.AddRange(BuildGroupList());
      context.Clients.AddRange(BuildClientsList());
      context.SaveChanges();

      this.AddUsersToGroup(context);
    }
        public IActionResult Register([FromBody] RegisterViewModel vm)
        {
            var user = new Users();

            user.Login     = vm.Login;
            user.BirthDate = vm.BirthDate;
            user.Pass      = vm.Password;
            user.FirstName = vm.FullName;
            user.Phone     = vm.PhoneNumber;
            db.Users.Add(user);
            db.Entry(user).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            db.SaveChanges();
            return(Json(new { success = true }));
        }
    private void AddUsersToGroup(PickMeAppContext context)
    {
      var infos = this.GetUserGroupInfo();
      var targetGroup = context.Groups.FirstOrDefault(g => g.Name == "Epam Systems Inc");
      var targetInfos = infos.Where(i => i.Value.GroupId == targetGroup.Id);

      if(targetGroup == null) return;

      this.TestUsers.ForEach(u =>
        {
          var userGroupTags = targetInfos.First(i => i.Key == u.Email).Value.Tags;
          this.AddUserToGroup(targetGroup, u.Email, userGroupTags, context);
        });

      context.SaveChanges();
    }