Example #1
0
        public void can_do_a_bulk_insert_against_the_child_type()
        {
            StoreOptions(_ =>
            {
                _.Schema.For <User>()
                .AddSubClass <AdminUser>()
                .AddSubClass <SuperUser>();
            });

            var users = new SuperUser[]
            {
                new SuperUser {
                    UserName = "******"
                },
                new SuperUser {
                    UserName = "******"
                },
                new SuperUser {
                    UserName = "******"
                },
                new SuperUser {
                    UserName = "******"
                }
            };

            theStore.BulkInsert(users);

            using (var query = theStore.LightweightSession())
            {
                query.Query <SuperUser>().Count().ShouldBe(4);
            }
        }
        public async Task <SuperUser> AddSuperUserToOrganization(SuperUser superUser)
        {
            _context.SuperUser.Add(superUser);
            await _context.SaveChangesAsync();

            return(superUser);
        }
Example #3
0
        public async Task <IHttpActionResult> CreateSuperUser(CreateSuperUserDTO model)
        {
            if (string.IsNullOrEmpty(model.Email))
            {
                return(BadRequest("email address is required"));
            }

            if (string.IsNullOrEmpty(model.Password))
            {
                return(BadRequest("password is required"));
            }

            var superUser = new SuperUser
            {
                Id        = Guid.NewGuid(),
                UserName  = model.Email,
                Email     = model.Email,
                FirstName = model.FirstName,
                Surname   = model.Surname
            };

            try
            {
                UnitOfWork.UserManager.AddOrUpdateUser(superUser, model.Password);
                await UnitOfWork.UserManager.AddToRoleAsync(superUser.Id, Role.SYSTEM_ADMINSTRATOR);

                MemoryCacher.Delete(CACHE_KEY);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #4
0
        public bool InsertUser(RegisterModel model)
        {
            using (dbContext = new UserManagerEntities())
            {
                User user;
                if (model.UserRole == UserType.SuperUser)
                {
                    user = new SuperUser();
                }
                else
                {
                    user = new UsualUser();
                }

                user.Email = model.Email;
                user.Login = model.Login;
                user.Password = model.Password;
                user.FirstName = model.FirstName;
                user.LastName = model.LastName;

                dbContext.Users.AddObject(user);
                dbContext.SaveChanges();
                return true;
            }
        }
        public string AddSuperUser(string strParams)
        {
            string             strError;
            RequestModelString reqinfo = ServerHlper.GetRequestModelString(System.Reflection.MethodBase.GetCurrentMethod().Name,
                                                                           strParams, out strError);

            if (reqinfo == null)
            {
                return(strError);
            }

            SuperUser mod = JsonStrObjConver.JsonStr2Obj(reqinfo.Info, typeof(SuperUser))
                            as SuperUser;

            if (mod == null)
            {
                return(ServerHlper.MakeInfoByStatus(false, "需要添加的用户参数不对"));
            }

            if (SuperUserBll.IsUserNameExist(mod.Name))
            {
                return(ServerHlper.MakeInfoByStatus(false, "需要添加的用户名已经存在"));
            }
            bool result = SuperUserBll.AddUser(ref mod, out strError);

            return(ServerHlper.MakeInfoByStatus(result, strError));
        }
        public void TheUsersAre(
            [Header("Tenant Id")] string tenant, 
            string UserName,
            [SelectionList("UserTypes")] string UserType)
        {
            User user = new User();
            switch (UserType)
            {
                case "User":
                    user = new User {UserName = UserName};
                    break;

                case "AdminUser":
                    user = new AdminUser {UserName = UserName};
                    break;

                case "SuperUser":
                    user = new SuperUser {UserName = UserName};
                    break;
            }

            _users.Add(user.UserName, user);

            using (var session = _store.OpenSession(tenant))
            {
                session.Store(user);
                session.SaveChanges();
            }
        }
Example #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            string strParmaInfo = "";

            GlareLedServices2.GLSysMgrSoapClient cl = new GlareLedServices2.GLSysMgrSoapClient();

            SuperUser userMod = new SuperUser()
            {
                Id         = 0,
                EnableTime = DateTime.Now,
                UserType   = 0,
                Name       = "bbb",
                Password   = "******"
            };
            string strInfo = JsonStrObjConver.Obj2JsonStr(userMod, typeof(SuperUser));

            RequestModelString obj2 = new RequestModelString()
            {
                Info   = strInfo,
                reqDt  = DateTime.Now,
                TockId = ConstDefineTestWebapi.TockIdEnableTest
            };

            strParmaInfo = JsonStrObjConver.Obj2JsonStr(obj2, typeof(RequestModelString));
            string strResult = cl.AddSuperUser(strParmaInfo);

            MessageBox.Show(strResult);
        }
        public async Task PatchResource_ModelWithEntityFrameworkInheritance_IsPatched()
        {
            // Arrange
            var dbContext  = PrepareTest <Startup>();
            var serializer = GetSerializer <SuperUser>(e => new { e.SecurityLevel, e.Username, e.Password });
            var superUser  = new SuperUser {
                SecurityLevel = 1337, Username = "******", Password = "******", LastPasswordChange = DateTime.Now.AddMinutes(-15)
            };

            dbContext.SuperUsers.Add(superUser);
            dbContext.SaveChanges();
            var su = new SuperUser {
                Id = superUser.Id, SecurityLevel = 2674, Username = "******", Password = "******"
            };
            var content = serializer.Serialize(su);

            // Act
            var(body, response) = await Patch($"/api/v1/superUsers/{su.Id}", content);

            // Assert
            AssertEqualStatusCode(HttpStatusCode.OK, response);
            var updated = _deserializer.DeserializeSingle <SuperUser>(body).Data;

            Assert.Equal(su.SecurityLevel, updated.SecurityLevel);
            Assert.Equal(su.Username, updated.Username);
            Assert.Equal(su.Password, updated.Password);
        }
Example #9
0
        static void Main(string[] args)
        {
            while (true)
            {
                LoginMenu NewMenu = new LoginMenu();
                User      User    = NewMenu.LoginScreen();


                if (User.Rank == UserRank.SuperAdmin)
                {
                    SuperAdmin User1    = new SuperAdmin(User.Username, UserRank.SuperAdmin);
                    Menus      NewMenu1 = new Menus();
                    NewMenu1.SuperAdminMenu(User1);
                }
                else if (User.Rank == UserRank.SuperUser)
                {
                    SuperUser User1    = new SuperUser(User.Username, UserRank.SuperUser);
                    Menus     NewMenu2 = new Menus();
                    NewMenu2.SuperUserMenu(User1);
                }
                else if (User.Rank == UserRank.DataEditor)
                {
                    DataEditor User1    = new DataEditor(User.Username, UserRank.DataEditor);
                    Menus      NewMenu3 = new Menus();
                    NewMenu3.DataEditorMenu(User1);
                }
                else
                {
                    DataViewer User1    = new DataViewer(User.Username, UserRank.DataViewer);
                    Menus      NewMenu4 = new Menus();
                    NewMenu4.DataViewerMenu(User1);
                }
            }
        }
Example #10
0
        public static bool AddUser(ref SuperUser model, out string strErrorMsg)
        {
            strErrorMsg = "";
            if (IsUserNameExist(model.Name))
            {
                strErrorMsg = ConstDefineBll.NameExist;
                return(false);
            }

            using (GLedDbEntities ent = new GLedDbEntities())
            {
                SuperUser newinfo = new SuperUser()
                {
                    Id         = model.Id,
                    EnableTime = model.EnableTime,
                    UserType   = model.UserType,
                    Name       = model.Name,
                    Password   = model.Password,
                    CreateDt   = DateTime.Now,
                    UpdateDt   = DateTime.Now
                };
                ent.SuperUser.Add(newinfo);
                ent.SaveChanges();
                model.Id = newinfo.Id;
            }
            return(true);
        }
Example #11
0
        public void AddUser()
        {
            if (Role == "Doctor")
            {
                var user = new Doctor(Firstname, Lastname, CIN, SelectedDate, Password, SuperUser, PhoneNumber, Role,
                                      City);
                DataContext.Context.Users.Add(user);
                user.Speciality = Speciality;
            }
            else if (Role == "Secretary")
            {
                var user = new Secretary(Firstname, Lastname, CIN, SelectedDate, Password, SuperUser, PhoneNumber, Role,
                                         City);
                DataContext.Context.Users.Add(user);
                user.ExperienceYears = YearsOfExp;
            }
            else if (Role == "Patient")
            {
                var user = new Patient(Firstname, Lastname, CIN, SelectedDate, Password, SuperUser, PhoneNumber, Role,
                                       City);
                DataContext.Context.Users.Add(user);
                user.Profession = Profession;
                user.LastVisit  = DateTime.Today.ToShortDateString();
            }
            else
            {
                var user = new SuperUser(Firstname, Lastname, CIN, SelectedDate, Password, SuperUser, PhoneNumber, Role,
                                         City);
                DataContext.Context.Users.Add(user);
                user.SuperPassword = SuperPassword;
            }
            DataContext.Context.SaveChanges();

            MessageBox.Show("User Added!");
        }
Example #12
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,NickName,IsActive,CanPublish,Resign,UserRoleId")] SuperUser superUser)
        {
            if (id != superUser.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(superUser);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SuperUserExists(superUser.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserRoleId"] = new SelectList(_context.UserRole, "Id", "Libelle", superUser.UserRoleId);
            return(View(superUser));
        }
Example #13
0
    static void Main(string[] args)
    {
        Guest g1 = new Guest(0, 0);

        g1.Create();
        LoggedUser l1 = new LoggedUser(5, 0991111111);

        l1.Create();
        Operator m1 = new Operator(901, 0992111111);

        m1.Create();
        CentalOperator a1 = new CentalOperator(1001, 0993111111);

        a1.Create();
        SuperUser su1 = new SuperUser(1, 1);

        su1.Create();
        Facade facade1 = new Facade(new Add_Sit(), new Calling());

        facade1.Operation1();
        facade1.Operation2();
        Calling cmntr1 = new Calling();
        Add_Sit artcl  = new Add_Sit();

        su1.SetCommand(new ArticleOnCommand(artcl));
        su1.DoSomething();
        su1.UndoSomething();
        su1.SetCommand(new CommentaryOnCommand(cmntr1));
        su1.DoSomething();
        su1.UndoSomething();

        Console.ReadLine();
    }
Example #14
0
        public void sub_level_of_hierarchy_is_deleted()
        {
            var user1 = new SuperUser {
                UserName = "******"
            };
            var user2 = new SuperUser {
                UserName = "******"
            };
            var user3 = new SuperUser {
                UserName = "******"
            };
            var user4 = new SuperUser {
                UserName = "******"
            };
            var user5 = new AdminUser {
                UserName = "******"
            };

            using var session = theStore.OpenSession();
            session.StoreObjects(new User[] { user1, user2, user3, user4, user5 });
            session.SaveChanges();

            session.DeleteWhere <SuperUser>(x => x.UserName.StartsWith("b"));
            session.SaveChanges();

            // no where clause
            session.Query <SuperUser>().Where(x => x.IsDeleted()).OrderBy(x => x.UserName).Select(x => x.UserName)
            .ToList().ShouldHaveTheSameElementsAs("bar", "baz");

            // with a where clause
            session.Query <SuperUser>().Where(x => x.UserName != "bar" && x.IsDeleted())
            .OrderBy(x => x.UserName)
            .Select(x => x.UserName)
            .ToList().ShouldHaveTheSameElementsAs("baz");
        }
        public ActionResult Modifier()
        {
            int       id        = Convert.ToInt32(Session["id_sup"]);
            SuperUser superUser = db.superUsers.Find(id);

            return(View(superUser));
        }
Example #16
0
        public ActionResult Create(SuperUser superuser)
        {
            string Path = AppDomain.CurrentDomain.BaseDirectory + @"greenpaperdev-firebase-adminsdk-8k2y5-fb46e63414.json";

            Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", Path);
            FirestoreDb db = FirestoreDb.Create("greenpaperdev");


            try
            {
                CollectionReference         col1  = db.Collection("SuperUsers");
                Dictionary <string, object> data1 = new Dictionary <string, object>
                {
                    { "UserId", superuser.UserId },
                    { "UserName", superuser.UserName },
                    { "Password", superuser.Password }
                };

                col1.AddAsync(data1);


                // TODO: Add insert logic here
                //var result = await fireBaseClient.Child("Students").PostAsync(std);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #17
0
        public async Task <ActionResult <SuperUser> > PostSuperUser(SuperUser superUser)
        {
            _context.SuperUser.Add(superUser);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSuperUser", new { id = superUser.Id }, superUser));
        }
Example #18
0
        public async Task <IActionResult> PutSuperUser(int id, SuperUser superUser)
        {
            if (id != superUser.Id)
            {
                return(BadRequest());
            }

            _context.Entry(superUser).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SuperUserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #19
0
 public static SuperUser getInstance(int id1, int ph1)
 {
     if (instance == null)
     {
         instance = new SuperUser(id1, ph1);
     }
     return(instance);
 }
Example #20
0
        public bool UpdateSuperUser(SuperUser SuperUser)
        {
            var item = _dbcontext.SuperUserModels.Where(a => a.id == SuperUser.id).FirstOrDefault();

            item = SuperUser;
            _dbcontext.SaveChanges();
            return(true);
        }
Example #21
0
 public static SuperUser getInstance(int id1, string l1)
 {
     if (instance == null)
     {
         instance = new SuperUser(id1, l1);
     }
     return(instance);
 }
Example #22
0
        public async Task <SuperUser> UpdateSuperUser(SuperUser superUser)
        {
            var originalSuperUser = await Get(superUser.Id);

            _context.Entry(originalSuperUser).CurrentValues.SetValues(superUser);

            await _context.SaveChangesAsync();

            return(originalSuperUser);
        }
        public IActionResult Giris(SuperUser superUser)
        {
            var newSuperUser = superUserRepository.Login(superUser);

            if (newSuperUser != null)
            {
                HttpContext.Session.SetString("SessionSuperUsername", superUser.Username);
                return(RedirectToAction("Index", "Yonetim"));
            }
            return(View(superUser));
        }
        public async Task <IHttpActionResult> GetSuperUser(int id)
        {
            SuperUser superUser = await db.SuperUsers.FindAsync(id);

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

            return(Ok(superUser));
        }
        public void AdminsCanViewAnyOngoingGameTheyAreNotIn()
        {
            CreateRoomRequest createRequest = new CreateRoomRequest()
            {
                Anonymous          = false,
                Goal               = Goal.Domination,
                MaxPlayers         = 2,
                IsRanked           = false,
                RoomName           = "My Room!",
                AllowedSpecialists = { "a", "b", "c" },
            };

            CreateRoomResponse roomResponse = client.CreateNewRoom(createRequest);

            Assert.AreEqual(roomResponse.Status.IsSuccess, true);
            Assert.IsTrue(roomResponse.CreatedRoom.RoomId != null);
            var roomId = roomResponse.CreatedRoom.RoomId;

            authHelper.loginToAccount("userTwo");

            JoinRoomRequest joinRequest = new JoinRoomRequest()
            {
                RoomId = roomId,
            };

            JoinRoomResponse joinResponse = client.JoinRoom(joinRequest);

            Assert.AreEqual(joinResponse.Status.IsSuccess, true);

            // Check to see the room is not visible.
            OpenLobbiesResponse openLobbiesResponseAfterJoin = client.GetOpenLobbies(new OpenLobbiesRequest());

            Assert.AreEqual(openLobbiesResponseAfterJoin.Status.IsSuccess, true);
            Assert.AreEqual(0, openLobbiesResponseAfterJoin.Rooms.Count);

            // Check to see the player can see the game because they are a member.
            PlayerCurrentGamesResponse playerGamesResponse = client.GetPlayerCurrentGames(new PlayerCurrentGamesRequest());

            Assert.AreEqual(playerGamesResponse.Status.IsSuccess, true);
            Assert.AreEqual(1, playerGamesResponse.Games.Count);

            SuperUser superUser = authHelper.CreateSuperUser();

            client.Login(new AuthorizationRequest()
            {
                Password = superUser.password,
                Username = superUser.userModel.UserModel.Username,
            });

            PlayerCurrentGamesResponse adminGamesResponse = client.GetPlayerCurrentGames(new PlayerCurrentGamesRequest());

            Assert.AreEqual(adminGamesResponse.Status.IsSuccess, true);
            Assert.AreEqual(1, adminGamesResponse.Games.Count);
        }
Example #26
0
 public IActionResult Ekle(SuperUser superUser)
 {
     if (ModelState.IsValid)
     {
         superUser.CreatedDate = DateTime.Now.ToShortDateString();
         superUser.Photo       = "Null";
         superUserRepository.AddModel(superUser);
         return(RedirectToAction("Index"));
     }
     return(View(superUser));
 }
 public ActionResult Inscription(SuperUser superUser)
 {
     if (ModelState.IsValid)
     {
         db.superUsers.Add(superUser);
         db.SaveChanges();
         Session["alerts"] = true;
         Session["id_sup"] = superUser.Id;
         return(RedirectToAction("EspaceSuperUser"));
     }
     return(View());
 }
        public void SuperUserAccountHasAdminClaims()
        {
            SuperUser superUser = RedisUserModel.CreateSuperUser().Result;

            // Fetch the user from the database.
            RedisUserModel user = RedisUserModel.GetUserFromGuid(superUser.userModel.UserModel.Id).Result;

            // Ensure the user has admin power
            Assert.IsTrue(user.HasClaim(UserClaim.Admin));
            Assert.IsTrue(user.HasClaim(UserClaim.Dev));
            Assert.IsTrue(user.HasClaim(UserClaim.EmailVerified));
        }
        public async Task <IHttpActionResult> PostSuperUser(SuperUser superUser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SuperUsers.Add(superUser);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = superUser.Id }, superUser));
        }
Example #30
0
        public async Task <IActionResult> Create([Bind("Id,NickName,IsActive,CanPublish,Resign,UserRoleId")] SuperUser superUser)
        {
            if (ModelState.IsValid)
            {
                _context.Add(superUser);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserRoleId"] = new SelectList(_context.UserRole, "Id", "Libelle", superUser.UserRoleId);
            return(View(superUser));
        }
Example #31
0
 public AuthController(IMapper mapper, UserManager <AppUser> userManager, RoleManager <Role> roleManager,
                       IConfiguration configuration, IOptions <JwtSettings> jwtSettings, CyberSoldierContext dbContext,
                       IOptions <SuperUser> superUser, IConvertErrorToCodeService convertErrorToCode, IEmailSender emailSender)
 {
     _mapper             = mapper;
     _userManager        = userManager;
     _roleManager        = roleManager;
     _configuration      = configuration;
     _dbContext          = dbContext;
     _convertErrorToCode = convertErrorToCode;
     _emailSender        = emailSender;
     _superUser          = superUser.Value;
     _jwtSettings        = jwtSettings.Value;
 }
 /// <summary>
 /// Automatically fills in the appropriate text in the forms from the given logged in user
 /// This should only be used when a user is logged in and their information is stored in the Session
 /// </summary>
 /// <param name="userType">Determines if user is a Researcher or Participant</param>
 private void autoFillForms(SuperUser.UserType userType)
 {
     SuperUser user = (SuperUser)Session["user"];
     int userID = user.UserID;
     switch (userType) {
         case SuperUser.UserType.Researcher:
             Researcher res = new Researcher(userID);
             tbResUserName.Text = res.UserName;
             tbResFirstName.Text = res.FirstName;
             tbResLastName.Text = res.LastName;
             tbResEmail.Text = res.Email;
             break;
         case SuperUser.UserType.Participant:
             Participant par = new Participant(userID);
             tbParUserName.Text = par.UserName;
             tbParFirstName.Text = par.FirstName;
             tbParLastName.Text = par.LastName;
             tbParEmail.Text = par.Email;
             break;
     }
 }
 /// <summary>
 /// Method that checks if the fields are correctly filled out before hitting 'submit' to try and create an account. 
 /// This is to disallow them to try and put in null fields, incorrect characters, etc
 /// </summary>
 /// <param name="user">Whether the user is trying to create a Researcher or Participant account</param>
 /// <returns>True if all fields are valid</returns>
 private bool isFormValid(SuperUser.UserType user)
 {
     switch (user) {
         case SuperUser.UserType.Participant:
             lblParStatus.Text = "";
             if (tbParPassword.Text == "" || tbParPassword.Text != tbParPasswordConfirm.Text) {
                 lblParStatus.Text = "Invalid Password, they do not match";
             }
             if (tbParLastName.Text == "") {
                 lblParStatus.Text = "Please enter your Last Name";
             }
             if (tbParFirstName.Text == "") {
                 lblParStatus.Text = "Please enter your First Name";
             }
             if (tbParUserName.Text == "") {
                 lblParStatus.Text = "Please enter a User Name";
             }
             if(!IsValidEmail(tbParEmail.Text)){
                 lblParStatus.Text = "Please enter a valid Email";
             }
             if (lblParStatus.Text != "") {
                 return false;
             }
             break;
         case SuperUser.UserType.Researcher:
             lblResStatus.Text = "";
             if (tbResPassword.Text == "" || tbResPassword.Text != tbResPasswordConfirm.Text) {
                 lblResStatus.Text = "Invalid Password";
             }
             if (tbResLastName.Text == "") {
                 lblResStatus.Text = "Please enter your Last Name";
             }
             if (tbResFirstName.Text == "") {
                 lblResStatus.Text = "Please enter your First Name";
             }
             if (tbResUserName.Text == "") {
                 lblResStatus.Text = "Please enter a User Name";
             }
             if (!IsValidEmail(tbResEmail.Text)){
                 lblResStatus.Text = "Please enter a valid Email";
             }
             if (lblResStatus.Text != "") {
                 return false;
             }
             break;
     }
     return true;
 }