public static Courtesan clone(Role toClone, SimDescription actor) { Courtesan newRole = new Courtesan(toClone.Data, actor, toClone.RoleGivingObject); newRole.StartRole(); return newRole; }
public User(string username, string password, Role role) { this.UserName = username; this.Password = password; this.Role = role; this.Courses = new HashSet<Course>(); }
public User() { _role = Roles.LOF.ToString(); _userRole = new Role { RoleName = Roles.LOF.ToString() }; Sex = OGender.Male; Md5 = string.Empty; }
private void _Setup() { Role role1 = new Role("Role1"); Role role2 = new Role("Role2"); Role role3 = new Role("Role3"); _roles = new List<Role> {role1, role2, role3}; }
public RoleIndexModel(Role role) { this.Role = role; IFunctionRepository repository = RepositoryFactory.GetRepository<IFunctionRepository, Function>(); IRoleRepository rolerepository = RepositoryFactory.GetRepository<IRoleRepository, Role>(); if (this.Role == null) return; this.AssignedFunctions = repository.FindByRole(this.Role).ToHashSet(); //找到父功能的权限 this.Role.Parent = rolerepository.FindParent(this.Role); if (this.Role.Parent == null) { this.UnAssignedFuncitons = repository.FindAll().ToHashSet().Except(this.AssignedFunctions).ToHashSet(); } else { this.UnAssignedFuncitons = repository.FindByRole(this.Role.Parent).ToHashSet().Except(this.AssignedFunctions).ToHashSet(); } }
protected void AP_SaveButton_Click(object sender, EventArgs e) { string roleName = AP_RoleTextBox.Text.Trim(); Role role = new Role(roleName); foreach (GridViewRow row in AP_PermissionGridView.Rows) { HiddenField hiddenField = (HiddenField)row.FindControl("PermissionIdHiddenField"); int permissionId = Convert.ToInt32(hiddenField.Value); foreach (KeyValuePair<int, Grant> item in Grant.Grants) { CheckBox checkBox = (CheckBox)row.FindControl(item.Value.Name+"CheckBox"); if (checkBox.Visible && checkBox.Checked) role.Rules[permissionId].Grants[item.Value.Id] = true; } } if (Role.CreateRole(role)) { InfoMessage("Yeni rol eklendi!."); RoleName = roleName; ActionName = EditPanel.ID; } else { ErrorMessage("Rol eklenirken hata oluþtu!.."); } }
public bool AddPerson(PersonModel person, Role role, string password) { if (person.Email == "") return false; return true; }
/// <summary> /// Returns the default audio endpoint for the specified data-flow direction and role. /// </summary> /// <param name="dataFlow">The data-flow direction for the endpoint device.</param> /// <param name="role">The role of the endpoint device.</param> /// <returns><see cref="MMDevice"/> instance of the endpoint object for the default audio endpoint device.</returns> public static MMDevice DefaultAudioEndpoint(DataFlow dataFlow, Role role) { using (var enumerator = new MMDeviceEnumerator()) { return enumerator.GetDefaultAudioEndpoint(dataFlow, role); } }
void Add(HttpContext context) { context.Response.ContentType = "application/json"; string name = context.Request["text"]; string msg = string.Empty; if (!string.IsNullOrWhiteSpace(name)) { try { Guid id= System.Guid.NewGuid() ; IList<Module> modules = RepositoryFactory<Modules>.Get().GetAll(); var query = from p in modules select new Right { ModuleId = p.Id , Permission = 0 , RoleId = id }; Role obj = new Role { Id =id, Name = context.Server.UrlDecode(name),Rights=query.ToList() }; RepositoryFactory<RolesRepository>.Get().Add(obj); context.Response.Write("{\"id\":\"" + obj.Id.ToString() + "\"}"); AppLog.Write("创建角色", AppLog.LogMessageType.Info,"name="+obj.Name,this.GetType()); } catch (Exception ex) { AppLog.Write("创建角色 出错" , AppLog.LogMessageType.Error , "name=" + name , ex , this.GetType()); msg = ex.Message; } } else { msg = "角色名不能为空"; } if (!string.IsNullOrWhiteSpace(msg)) { context.Response.Write("{\"msg\":\""+msg+"\"}"); } }
public unsafe int GetDefaultAudioEndpointNative(DataFlow dataFlow, Role role, out IntPtr device) { IntPtr pdevice; int result = InteropCalls.CallI(_basePtr, unchecked(dataFlow), unchecked(role), &pdevice, ((void**)(*(void**)_basePtr))[4]); device = pdevice; return result; }
public static Anysim clone(Role toClone, SimDescription actor) { Anysim newRole = new Anysim(toClone.Data, actor, toClone.RoleGivingObject); newRole.StartRole(); return newRole; }
public UserManager_Permission_Tests() { _role1 = CreateRole("Role1").Result; _role2 = CreateRole("Role2").Result; _testUser = CreateUser("TestUser").Result; AsyncHelper.RunSync(() => UserManager.AddToRolesAsync(_testUser.Id, _role1.Name, _role2.Name)).CheckErrors(); }
public void Given_all_required_fields_are_available_Then_create_user_method_creates_an_object() { //Given Guid userId = Guid.NewGuid(); const long companyId = 33749; const long siteId = 324234L; var role = new Role() { Id = new Guid("BACF7C01-D210-4DBC-942F-15D8456D3B92") }; var user = new UserForAuditing() { Id = new Guid("B03C83EE-39F2-4F88-B4C4-7C276B1AAD99") }; var site = new Site() {Id = siteId}; var employeeContactDetail = new EmployeeContactDetail {Email = "*****@*****.**"}; var employee = new Employee {Forename = "Gary", Surname = "Green",ContactDetails = new List<EmployeeContactDetail> {employeeContactDetail}}; //When var result = User.CreateUser(userId, companyId, role, site, employee, user); //Then Assert.That(result.Id, Is.EqualTo(userId)); Assert.That(result.CompanyId, Is.EqualTo(companyId)); Assert.That(result.Site.Id, Is.EqualTo(siteId)); Assert.That(result.Employee, Is.Not.Null); Assert.That(result.Employee.Forename, Is.EqualTo("Gary")); Assert.That(result.Employee.Surname, Is.EqualTo("Green")); Assert.That(result.Employee.ContactDetails, Is.Not.Null); Assert.That(result.Employee.ContactDetails.Count, Is.EqualTo(1)); Assert.That(result.Employee.ContactDetails[0].Email, Is.EqualTo("*****@*****.**")); }
public void VerifySavingParentParentObjectPreservesDeepestChildren() { SetUp(); User user = new User(); user.Username = "******"; Role role = new Role(); role.Name = "admin"; user.Roles.Add(role); user.Save(); user = User.SelectFirst(); Assert.AreEqual(1, user.Roles.Count); Assert.AreEqual("admin", user.Roles[0].Name); Article a = new Article(); a.Header = "sdfihsdf"; a.Body = "sdfiojhsdf"; a.Followers.Add(user); a.Author = user; a.Save(); user = User.SelectFirst(); Assert.AreEqual(1, user.Roles.Count); Assert.AreEqual("admin", user.Roles[0].Name); }
public void SaveToDB(int matchNo, DateTime matchDay, Location location, Role role, MatchDayShort matchDayShort, char matchType, int round, string row, DrivingInfo drivingInfo, Team homeTeam, Team awayTeam) { using (var conn = new MySqlConnection(ConnectionString)) { conn.Open(); var locationId = GetLocationId(location); var homeTeamId = GetTeamId(homeTeam); var awayTeamId = GetTeamId(awayTeam); var cmd = new MySqlCommand( "INSERT INTO DbuGrabber_Game " + "(GameNo, Round, GameDayShort, GameDay, Row, LocationId, HomeTeamId, AwayTeamId, Role, DrivingHours, DrivingMinutes, MatchType) " + "VALUES " + "(@GameNo, @Round, @GameDayShort, @GameDay, @Row, @LocationId, @HomeTeamId, @AwayTeamId, @Role, @DrivingHours, @DrivingMinutes, @MatchType)" + " ON DUPLICATE KEY UPDATE Round = @Round, GameDayShort = @GameDayShort, GameDay = @GameDay, Row = @Row, LocationId = @LocationId, HomeTeamId= @HomeTeamId, AwayTeamId = @AwayTeamId, Role = @Role, DrivingHours = CASE WHEN (DrivingHours <> @DrivingHours) THEN @DrivingHours ELSE DrivingHours END, DrivingMinutes = CASE WHEN (DrivingMinutes <> @DrivingMinutes) THEN @DrivingMinutes ELSE DrivingMinutes END, MatchType= @MatchType, Sent = CASE WHEN (DrivingHours <> @DrivingHours OR DrivingMinutes <> @DrivingMinutes) THEN 0 ELSE Sent END", conn); cmd.Parameters.AddWithValue("@GameNo", matchNo); cmd.Parameters.AddWithValue("@Round", round); cmd.Parameters.AddWithValue("@GameDayShort", matchDayShort.ToString()); cmd.Parameters.AddWithValue("@GameDay", matchDay); cmd.Parameters.AddWithValue("@Row", row); cmd.Parameters.AddWithValue("@LocationId", locationId); cmd.Parameters.AddWithValue("@HomeTeamId", homeTeamId); cmd.Parameters.AddWithValue("@AwayTeamId", awayTeamId); cmd.Parameters.AddWithValue("@Role", role.ToString()); cmd.Parameters.AddWithValue("@DrivingHours", drivingInfo.Hours); cmd.Parameters.AddWithValue("@DrivingMinutes", drivingInfo.Minutes); cmd.Parameters.AddWithValue("@MatchType", matchType); cmd.ExecuteNonQuery(); } }
public IEnumerable<AgentAuthorizeAction> GetAuthByRole(Role role) { string sql = string.Format(@"select aaa.* from tb_AgentAuthorizeAction aaa join tb_AgentAuthorizeInRole aar on aar.AuthorizeId=aaa.AuthorizeId where aar.{0}=@{0}", AgentAuthorizeInRole.ROLEID); return base.ExecuteList<AgentAuthorizeAction>(sql, new SqlParameter(AgentAuthorizeInRole.ROLEID, (int)role)); }
public void AddRole(Role role) { if (RoleExists(role)) throw new ArgumentException(TooManyRole); entities.Roles.Add(role); }
// POST odata/Role public virtual async Task<IHttpActionResult> Post(Role role) { if (!ModelState.IsValid) { return BadRequest(ModelState); } try { await MainUnitOfWork.InsertAsync(role); } catch (DbUpdateException) { if (MainUnitOfWork.Exists(role.Id)) { return Conflict(); } else { throw; } } return Created(role); }
public User(string username, string password, Role role) { if (username == null || username == string.Empty) { string message = string.Format("The username must be at least 5 symbols long."); throw new ArgumentException(message); } if (username.Length < 5) { string message = string.Format("The username must be at least 5 symbols long."); throw new ArgumentException(message); } this.UserName = username; if (password == null || password == string.Empty) { string message = string.Format("The password must be at least 5 symbols long."); throw new ArgumentException(message); } if (password.Length < 5) { string message = string.Format("The username must be at least 5 symbols long."); throw new ArgumentException(message); } string passwordHash = HashUtilities.HashPassword(password); this.Password = passwordHash; this.Role = role; this.Courses = new List<Course>(); }
/// <summary> /// Initializes a new instance of the <see cref="User"/> class. /// </summary> /// <param name="userName">Name of the user.</param> /// <param name="roles">The role.</param> public User(string userName, Role role = null) { this.UserName = userName; if (role != null) Role = role; }
// PUT odata/Role(5) public virtual async Task<IHttpActionResult> Put([FromODataUri] int key, Role role) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (key != role.Id) { return BadRequest(); } try { await MainUnitOfWork.UpdateAsync(role); } catch (DbUpdateConcurrencyException) { if (!MainUnitOfWork.Exists(key)) { return NotFound(); } else { return Conflict(); } } return Ok(role); }
public User CreateUser(string userName, string password, Role role, long? deleteTime) { int? itemId = itemRepository.GenerateItemId(ItemType.User); if (itemId == null) { return null; } // Verify user doesn't exist in cache if (this.Users.Values.Any(x => x.UserName == userName)) { return new User(); } string salt = User.GeneratePasswordSalt(); string hash = User.ComputePasswordHash(password, salt); var u = new User(); u.UserId = itemId; u.UserName = userName; u.Role = role; u.Password = password; u.PasswordHash = hash; u.PasswordSalt = salt; u.CreateTime = DateTime.UtcNow.ToUnixTime(); u.DeleteTime = deleteTime; this.database.InsertObject<User>(u); this.ReloadUsers(); return u; }
protected void btnUpdate_Click(object sender, EventArgs e) { string loginID = "1"; try { if (Session["Login"] == null) { Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("../LoginPage.aspx"); } loginID = ((Login)Session["Login"]).LoginID.ToString(); } catch (Exception ex) { } Role role = new Role(); role = RoleManager.GetRoleByID(Int32.Parse(Request.QueryString["roleID"])); Role tempRole = new Role(); tempRole.RoleID = role.RoleID; tempRole.RoleName = txtRoleName.Text; tempRole.RoleDescription = txtRoleDescription.Text; tempRole.AddedDate = DateTime.Now; tempRole.AddedBy = loginID; tempRole.ModifyDate = DateTime.Now; tempRole.ModifyBy = loginID; tempRole.RowStatusID = Int32.Parse(ddlRowStatus.SelectedValue); bool result = RoleManager.UpdateRole(tempRole); Response.Redirect("AdminRoleDisplay.aspx"); }
public TcpipClient(string host, int port, Role? requestRole) { this.host = host; this.port = port; this.RequestRole = requestRole; Running = false; }
public LoginWindow(Role[] roles, ApplicationManager appMgr) { InitializeComponent(); this.appMgr = appMgr; this.authRoles = roles; this.isRoleAuth = true; }
/// <summary> /// Add Role in database /// </summary> /// <param name="pRole"></param> /// <returns>Role id</returns> public int AddRole(Role pRole) { const string q = @"INSERT INTO [Roles] ([deleted], [code], [description], [role_of_loan], [role_of_saving], [role_of_teller]) VALUES(@deleted, @code, @description, @role_of_loan, @role_of_saving, @role_of_teller) SELECT SCOPE_IDENTITY()"; using (SqlConnection conn = GetConnection()) { using (OpenCbsCommand c = new OpenCbsCommand(q, conn)) { c.AddParam("@deleted", false); c.AddParam("@code", pRole.RoleName); c.AddParam("@description", pRole.Description); c.AddParam("@role_of_loan", pRole.IsRoleForLoan); c.AddParam("@role_of_saving", pRole.IsRoleForSaving); c.AddParam("@role_of_teller", pRole.IsRoleForTeller); pRole.Id = int.Parse(c.ExecuteScalar().ToString()); SaveRoleMenu(pRole); SaveAllowedActionsForRole(pRole); } } return pRole.Id; }
public User(string username, string password, Role role) { this.Username = username; this.PasswordHash = password; this.Role = role; this.Bookings = new List<Booking>(); }
public static IUser Get(Command cmd, string id, Role role) { string table = null; string columns = null; switch (role) { case Role.Administrator: table = Administrator.Table; columns = string.Join(",", Administrator.Properties.Select(p => p.Name).ToArray()); break; case Role.Teacher: table = Teacher.Table; columns = string.Join(",", Teacher.Properties.Select(p => p.Name).ToArray()); break; case Role.Student: table = Student.Table; columns = string.Join(",", Student.Properties.Select(p => p.Name).ToArray()); break; } string sql = string.Format(@"select {0} from {1} where lower(Id)=lower(@Id)", columns, table); cmd.CommandText = sql; cmd.AddParameter("@Id", id); SqlCeDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { IUser user = ReaderFactory.Reader(reader, role.ToEntity()) as IUser; reader.Close(); return user; } reader.Close(); return null; }
public static Boolean Validate(String Token, Role pRole) { if (Role.ALL == pRole) { return true; } var boolResult = false; try { using(var sessionManagerDal = new SessionManagerDAL(Util.GetConnection())) { var lstObjSessionManager = sessionManagerDal.SessionManagerDAL_ById(Token).ToList(); if (lstObjSessionManager.Count() == 1) { switch ((Role)lstObjSessionManager[0].UserRole) { case Role.ADMIN: case Role.CLIENT: boolResult = true; break; case Role.NONE: boolResult = false; break; default: throw new Exception("Not accessible, unknow userRole"); } } } } catch (Exception ex) { throw; } return boolResult; }
public void TestCreate() { var dao = "RoleReponsitory".GetInstance<IRoleReponsitory>(); var role = new Role { AuthorityScript = "1 + 1", Description = "", Name = "���Խ�ɫ", ActionKeys = new HashSet<string>() { "1", "2", "3" }, Children = new HashSet<IRole>() { new Role { Name = "�����ӽ�ɫ", AuthorityScript = "true", ActionKeys = new HashSet<string>{"1.2", "1.3"} } } }; var role2 = new Role { AuthorityScript = "0", Name = "�ű���ɫ" }; Log.Debug("--------------------------------------------------------------------"); dao.Add(role); dao.Add(role2); //dao.Test(role); Log.Debug("--------------------------------------------------------------------"); //dao.Remove(role); Log.Debug("--------------------------------------------------------------------"); }
public void CreateNew(Role role) { _roleRepository.CreateNew(role); }
public async Task SetRoleNameAsync(Role role, string name, CancellationToken cancel) { role.Name = name; await PostAsync($"{_ServiceAddress}/SetRoleName/{name}", role, cancel); }
public async Task <string> GetRoleNameAsync(Role role, CancellationToken cancel) => await(await PostAsync($"{_ServiceAddress}/GetRoleName", role, cancel)) .Content .ReadAsAsync <string>(cancel);
public async Task <IdentityResult> DeleteAsync(Role role, CancellationToken cancel) => await(await PostAsync($"{_ServiceAddress}/Delete", role, cancel)) .Content .ReadAsAsync <bool>(cancel) ? IdentityResult.Success : IdentityResult.Failed();
public async Task <IdentityResult> UpdateAsync(Role role, CancellationToken cancel) => await(await PutAsync(_ServiceAddress, role, cancel)) .Content .ReadAsAsync <bool>(cancel) ? IdentityResult.Success : IdentityResult.Failed();
public double GetViabilityByLane(Role a_Lane) { return Viability.GetViabilityByLane(a_Lane); }
public void Update(Role role) { _roleRepository.Update(role); }
public void Save(Role value) { CurrentSession.SaveOrUpdate(value); }
public virtual bool DoMatchCollection(Role role, INode pos, Match match, BacktrackingInfo backtrackingInfo) { return(DoMatch(pos, match)); }
public void Delete(Role value) { value.DeletionDate = DateTime.Now; CurrentSession.SaveOrUpdate(value); }
public int AddRole(Role role) { _db.Roles.Add(role); _db.SaveChanges(); return(role.RoleID); }
public AttackCommand(Role attacker, Role defender) { this.attacker = attacker; this.defender = defender; damage = 0; }
protected override void Seed(NewForumProject.DAL.DataContext context) { var academies = new List <Academy> { new Academy { AcademyName = "Hadassah" }, new Academy { AcademyName = "JCE" } }; //Fill table from ForumContext with data. academies.ForEach(s => context.Academies.Add(s)); var courses = new List <Subject> { new Subject { SubjectName = "Chemistry", Academy = academies.First(), LectureType = TypeOfLecture.Lecture, MustAttend = true }, new Subject { SubjectName = "Microeconomics", Academy = academies.First(), LectureType = TypeOfLecture.Lab, MustAttend = false }, new Subject { SubjectName = "Macroeconomics", Academy = academies.First(), LectureType = TypeOfLecture.Presentation, MustAttend = true }, new Subject { SubjectName = "Calculus", Academy = academies.First(), LectureType = TypeOfLecture.Practice, MustAttend = false }, new Subject { SubjectName = "Trigonometry", Academy = academies.First(), LectureType = TypeOfLecture.Lecture, MustAttend = true }, new Subject { SubjectName = "Composition", Academy = academies.First(), LectureType = TypeOfLecture.Seminar, MustAttend = true }, new Subject { SubjectName = "Literature", Academy = academies.First(), LectureType = TypeOfLecture.Lab, MustAttend = false } }; //Fill table from ForumContext with data. courses.ForEach(s => context.Subjects.Add(s)); Role role1 = new Role { RoleName = "Admin", Description = "Administrator" }; Role role2 = new Role { RoleName = "User", Description = "Simple User" }; Password adminPass = new Password("123456", -1361166414); Password userPass = new Password("123456", 1361676414); User user1 = new User { Username = "******", Email = "*****@*****.**", FirstName = "Daniel", LastName = "Shwarcman", Password = adminPass.ComputeSaltedHash(), IsActive = true, CreateDate = DateTime.UtcNow, Roles = new List <Role>(), Academy = academies.First(), Salt = -1361166414 }; User user2 = new User { Username = "******", Email = "*****@*****.**", FirstName = "Vasiliy", LastName = "Pupkin", Password = userPass.ComputeSaltedHash(), IsActive = true, CreateDate = DateTime.UtcNow, Roles = new List <Role>(), Academy = academies.First(), Salt = 1361676414 }; User user3 = new User { Username = "******", Email = "*****@*****.**", FirstName = "Masha", LastName = "Nenasha", Password = userPass.ComputeSaltedHash(), IsActive = true, CreateDate = DateTime.UtcNow, Roles = new List <Role>(), Academy = academies.First(), Salt = 1361676414 }; User user4 = new User { Username = "******", Email = "*****@*****.**", FirstName = "Vitaliy", LastName = "Genetaliy", Password = userPass.ComputeSaltedHash(), IsActive = true, CreateDate = DateTime.UtcNow, Roles = new List <Role>(), Academy = academies.First(), Salt = 1361676414 }; User user5 = new User { Username = "******", Email = "*****@*****.**", FirstName = "Sveta", LastName = "Konfeta", Password = userPass.ComputeSaltedHash(), IsActive = true, CreateDate = DateTime.UtcNow, Roles = new List <Role>(), Academy = academies.First(), Salt = 1361676414 }; User user6 = new User { Username = "******", Email = "*****@*****.**", FirstName = "Tatiana", LastName = "Nesmeyana", Password = userPass.ComputeSaltedHash(), IsActive = true, CreateDate = DateTime.UtcNow, Roles = new List <Role>(), Academy = academies.First(), Salt = 1361676414 }; User user7 = new User { Username = "******", Email = "*****@*****.**", FirstName = "Kolya", LastName = "Bezjazikov", Password = userPass.ComputeSaltedHash(), IsActive = true, CreateDate = DateTime.UtcNow, Roles = new List <Role>(), Academy = academies.First(), Salt = 1361676414 }; user1.Roles.Add(role1); user2.Roles.Add(role2); user3.Roles.Add(role2); user4.Roles.Add(role2); user5.Roles.Add(role2); user6.Roles.Add(role2); user7.Roles.Add(role2); context.Users.Add(user1); context.Users.Add(user2); context.Users.Add(user3); context.Users.Add(user4); context.Users.Add(user5); context.Users.Add(user6); context.Users.Add(user7); Block block = new Block { Date = DateTime.Now, BlockedUserID = user2.UserID, BlockedUser = user2, BlockerUserID = user1.UserID, BlockerUser = user1 }; context.Blocks.Add(block); context.SaveChanges(); }
public void DeleteRole(Role role) { role.isDelete = true; Updaterole(role); }
public ActionResult Edit(HttpPostedFileBase profileFile, EmployeeModel reporter) { reporter.UniqueTitle = VITV.Web.Helpers.UrlHelper.URLFriendly(reporter.Name); if (profileFile != null && profileFile.ContentLength > 0) { string fileName = Convert.ToInt32((DateTime.Now - new DateTime(2010, 01, 01)).TotalSeconds) + "_" + profileFile.FileName; string currentDomain = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"]; string folder = "UploadedImages/profilepicture"; string filePath = System.Configuration.ConfigurationManager.AppSettings[currentDomain] + @"\" + folder + @"\" + fileName; using (new Impersonator("uploaduser", "", "Upload@@123")) { profileFile.SaveAs(filePath); } reporter.ProfilePicture = currentDomain + "/" + folder + "/" + fileName; } else if (String.IsNullOrEmpty(reporter.ProfilePicture)) { reporter.ProfilePicture = "/Images/default-avatar.png"; } ModelState.Clear(); TryValidateModel(reporter); if (ModelState.IsValid) { var reporterEn = AutoMapper.Mapper.Map <EmployeeModel, Employee>(reporter); _reporterRepository.Load(reporterEn, a => a.Roles); if (reporter.Roles != null) { List <Role> lstTemp = reporterEn.Roles.ToList(); foreach (Role r in lstTemp) { reporterEn.Roles.Remove(r); } foreach (int i in reporter.Roles) { Role r = _roleRepository.Find(i); reporterEn.Roles.Add(r); } } else { List <Role> lstTemp = reporterEn.Roles.ToList(); foreach (Role r in lstTemp) { reporterEn.Roles.Remove(r); } } var personalInfo = context.EmployeePersonalInfos.Find(reporter.Id); if (personalInfo == null) { personalInfo = new EmployeePersonalInfo { Id = reporter.Id }; } personalInfo.Biography = reporter.Biography; personalInfo.Email = reporter.Email; personalInfo.Introduction = reporter.Introduction; personalInfo.Phone = reporter.Phone; _reporterRepository.InsertOrUpdate(reporterEn); _reporterRepository.InsertOrUpdate(personalInfo); _reporterRepository.Save(); return(RedirectToAction("Management")); } return(View(reporter)); }
public void Updaterole(Role role) { _db.Roles.Update(role); _db.SaveChanges(); }
/// <summary> /// 撞击处理 /// </summary> /// <param name="Damage">撞击伤害</param> /// <param name="dir">撞击方向</param> /// <param name="Info">返回撞击信息</param> /// <returns></returns> public override void CollisionProcByFire(Collision collision, int Damage/*,Vector2 dir*/, ref FlyCollisionInfo Info, FlyDir flydir) { //惊醒防御方 Role.WakeEnemy(this); Info.bVertical = m_bVertical; Info.FlyfallSTandGridPos = new Int2(StartUnit, Layer); Info.lifemCollision = this; SkillReleaseInfo sInfo = new SkillReleaseInfo(); sInfo.m_InterruptSkill = false; sInfo.m_MakeStatus = new List<StatusType> (); sInfo.m_bImmunity = false; sInfo.m_Damage = Damage; sInfo.Result = AttackResult.Fire; ApplyDamage(sInfo, null); //........................................................................ // 需要继续查.......................... if (m_DefenceColider == null) { isDead = true; } //........................................................................ if (isDead) { //穿了 GameObjectActionExcute gae = EffectM.LoadEffect(EffectM.sPath, "2000291", collision.contacts[0].point, BattleEnvironmentM.GetLifeMBornNode(true)); GameObjectActionDelayDestory ndEffect = new GameObjectActionDelayDestory(1f); gae.AddAction(ndEffect); Info.flyCollisionAction = FlyCollisionAction.PauseContinueFlyDirectional; Info.bApplyDamage = true; MakeHole(); } else { if (Info.bReleaseSkill) { shake(collision.contacts[0].point); SetDamageTexture(); GameObjectActionExcute gae = EffectM.LoadEffect(EffectM.sPath, "2000281", collision.contacts[0].point, BattleEnvironmentM.GetLifeMBornNode(true)); GameObjectActionDelayDestory ndEffect = new GameObjectActionDelayDestory(1f); gae.AddAction(ndEffect); } if (flydir == FlyDir.LeftTop || flydir == FlyDir.RightTop || flydir == FlyDir.Top) { if (m_FloorType == FloorType.bottom) { Info.flyCollisionAction = FlyCollisionAction.DropOutBoat; } else { Info.flyCollisionAction = FlyCollisionAction.DropInBoat; } Info.bApplyDamage = false; } else if (flydir == FlyDir.LeftBottom || flydir == FlyDir.RightBottom || flydir == FlyDir.Bottom) { Info.flyCollisionAction = FlyCollisionAction.FlyFallStand; Info.bApplyDamage = false; } else { if (m_FloorType == FloorType.top) { Info.flyCollisionAction = FlyCollisionAction.FlyFallStand; Info.bApplyDamage = false; } else if (m_DefenceColider.IsInBottomCollider(collision.collider)) { if (m_FloorType == FloorType.bottom) { Info.flyCollisionAction = FlyCollisionAction.DropOutBoat; } else { Info.flyCollisionAction = FlyCollisionAction.DropInBoat; } Info.bApplyDamage = false; } else if (m_DefenceColider.IsInTopCollider(collision.collider)) { //从上往下撞 Info.flyCollisionAction = FlyCollisionAction.FlyFallStand; Info.bApplyDamage = false; } } } }
private void SeedIdentity() { var role = _dbContext.Set <Role>() .Include(r => r.Permissions) .FirstOrDefault(r => r.Name == RoleNames.Administrators); if (role == null) { role = new Role { Name = RoleNames.Administrators, NormalizedName = RoleNames.Administrators.ToUpperInvariant(), Description = "حذف گروه کاربری پیش فرض «مدیران سیستم» باعث ایجاد اختلال در کارکرد صحیح سیستم خواهد شد.", }; _dbContext.Set <Role>().Add(role); } else { _logger.LogInformation($"{nameof(Seed)}: Administrators role already exists."); } var rolePermissionNames = role.Permissions.Select(a => a.Name).ToList(); var allPermissionNames = PermissionNames.NameList; var newPermissions = allPermissionNames.Except(rolePermissionNames) .Select(permissionName => new RolePermission { Name = permissionName }).ToList(); role.Permissions.AddRange(newPermissions); _logger.LogInformation( $"{nameof(Seed)}: newPermissions: {string.Join("\n", newPermissions.Select(a => a.Name))}"); var admin = _settings.Value.UserSeed; var user = _dbContext.Set <User>() .Include(u => u.Permissions) .Include(u => u.Roles) .FirstOrDefault(u => u.NormalizedUserName == admin.UserName.ToUpperInvariant()); if (user == null) { user = new User { UserName = admin.UserName, NormalizedUserName = admin.UserName.ToUpperInvariant(), DisplayName = admin.DisplayName, NormalizedDisplayName = admin.DisplayName, //.NormalizePersianTitle(), IsActive = true, PasswordHash = _password.HashPassword(admin.Password), SecurityStamp = Guid.NewGuid().ToString("N") }; _dbContext.Set <User>().Add(user); } else { _logger.LogInformation($"{nameof(Seed)}: Admin user already exists."); } if (user.Roles.All(ur => ur.RoleId != role.Id)) { _dbContext.Set <UserRole>().Add(new UserRole { Role = role, User = user }); } else { _logger.LogInformation($"{nameof(Seed)}: Admin user already is assigned to Administrators role."); } user.Permissions.Clear(); _dbContext.SaveChanges(); }
public static void Initialize(AuctionContext context) { context.Database.EnsureCreated(); if (context.Auctions.Any()) { return; } // Auctions var auctions = new Auction[] { new Auction { Name = "Auction of August 2017", StartDate = new DateTime(2017, 7, 10), EndDate = new DateTime(2017, 8, 15) } }; foreach (Auction auction in auctions) { context.Auctions.Add(auction); } context.SaveChanges(); //Need to save everytime if using Ids // Sponsors var sponsors = new Sponsor[] { // Accommodation new Sponsor { Name = "Trisara", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, new Sponsor { Name = "Le Meridien Phuket Beach Resort", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, new Sponsor { Name = "Andara Resort & Villas", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, new Sponsor { Name = "The Surin Phuket", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, new Sponsor { Name = "Mövenpick Resort, Bangtao Beach Phuket", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, // Advertising new Sponsor { Name = "Khao Phuket", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, new Sponsor { Name = "Novosti Phuket", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, new Sponsor { Name = "The Phuket News TV", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, // Dining (+Accomodation +Lifestyle) new Sponsor { Name = "Burasari Resort", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, new Sponsor { Name = "The Siam Supper Club", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, // Entertainment new Sponsor { Name = "H3 Digital Limited", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, // Lifestyle (+Dinning, + Accomodation) new Sponsor { Name = "Novotel Phuket Kamala Beach", StartDate = new DateTime(2017, 7, 10), Phone = "5555555555" }, }; foreach (Sponsor sponsor in sponsors) { context.Sponsors.Add(sponsor); } context.SaveChanges(); // Catagories var accommodationCategory = new Category { Name = "Accommodation" }; context.Categories.Add(accommodationCategory); var advertisingCategory = new Category { Name = "Advertising" }; context.Categories.Add(advertisingCategory); var diningCategory = new Category { Name = "Dining" }; context.Categories.Add(diningCategory); var entertainmentCategory = new Category { Name = "Entertainment" }; context.Categories.Add(entertainmentCategory); var lifestyleCategory = new Category { Name = "Lifestyle" }; context.Categories.Add(lifestyleCategory); context.SaveChanges(); // Items var items = new Item[] { // Accommodation new Item { Name = "2 Nights Accommodation in an Ocean View Pool Villa at Trisara", Description = "Enjoy a two night stay in a spectacular Ocean View Pool Villa at Trisara, inclusive of 2x Trisara spa treatments, daily breakfast and the Trisara Sunday Jazz Brunch for 2.", Category = accommodationCategory, RetailPrice = 100, SponsorId = sponsors[0].Id, Sponsor = sponsors[0], OfferExpires = "May 10, 2018", Terms = "This certificate is valid from 30 May 17 – 10 May 18; except : 01 – 07 Oct 17, 20 Dec 17 – 20 Jan 18 and subject to availability only. This certificate is neither transferable nor redeemable for cash. At least 7 days advance reservation is required." }, new Item { Name = "2 Nights Accommodation at Le Meridien Phuket Beach Resort + 2 Dinners", Description = "Enjoy a 3 day 2 night stay for two persons at the Le Meridien Phuket Beach Resort in an Ocean Front Deluxe Suite including daily buffet breakfast and one dinner at Portofino including a bottle of house wine and one dinner at Ariake including a carafe of Sake.", Category = accommodationCategory, RetailPrice = 60, SponsorId = sponsors[1].Id, Sponsor = sponsors[1], OfferExpires = "May 31, 2018", Terms = "Voucher is valid from 1 June 2017 to 31 May 2018. Blackout dates: 21 December 2017 to 28 February 2018. Gift voucher will be issued once the full name of the winner is determined. The original gift voucher will be non-transferable to anyone other than the person’s name stated on the voucher. Presentation of the original gift voucher is required upon check-in to avail the offer. Prior reservation is required and based on space availability." }, new Item { Name = "1 Night Accommodation at Andara Resort + In-Suite BBQ w/ Champagne", Description = "Enjoy a 1-night stay in a 4-bedroom Pool Suite at Andara Resort & Villas with daily breakfast at SILK Restaurant and a BBQ for 8 persons in your Suite Room with your own private chef accompanied by 2 bottles of Louis Roederer Champagne.", Category = accommodationCategory, RetailPrice = 60, SponsorId = sponsors[2].Id, Sponsor = sponsors[2], OfferExpires = "November 30, 2017", Terms = "Valid for stays between 15 May and 30 November 2017. Maximum 8 people only. Voucher cannot be redeemed for cash and used in conjunction with other promotions. Reservation is required 14 days in advance, subject to space availability Cancellation is 3 days written notice to Andara to prior arrival" }, new Item { Name = "3 Nights Accommodation at The Surin Phuket", Description = "Enjoy a 3 night stay for two persons at The Surin Phuket in a Beach Deluxe Suite including daily buffet breakfast with signature dinner & spa treatment.", Category = accommodationCategory, RetailPrice = 60, SponsorId = sponsors[3].Id, Sponsor = sponsors[3], OfferExpires = "June 30, 2018", Terms = "Validity dates: 1 June 2017 to 30 June 2018. Blackout dates: 21 December 2017 to 28 February 2018. Signature set dinner is for 2 persons(food only) at any outlets. Spa treatment is for 2 persons(60 minutes). Presentation of the original gift voucher is required upon check -in. Prior reservation is required and based on space availability. Non - redeemable, non - refundable and prize is non - transferable." }, new Item { Name = "2 Nights Accommodation at Mövenpick Resort, Bangtao Beach Phuket", Description = "Enjoy a 2-night stay in a Seaview Pool Suite 1 Bedroom inclusive of breakfast for two at The Palm Cuisine at the Mövenpick Resort, Bangtao Beach Phuket.", Category = accommodationCategory, RetailPrice = 60, SponsorId = sponsors[4].Id, Sponsor = sponsors[4], OfferExpires = "December 01, 2017", Terms = "Valid for stay from now to 15 December 2017" }, // Advertising new Item { Name = "Half Page Advert in Khao Phuket (The Phuket News in Thai)", Description = "Receive one 1/2 page advertisement — 274mm (w) x 189mm (h) – in Khao Phuket (The Phuket News in Thai), including artwork and translation.", Category = advertisingCategory, RetailPrice = 60, SponsorId = sponsors[5].Id, Sponsor = sponsors[5], OfferExpires = "January 01, 2018" }, new Item { Name = "Half Page Advert in Novosti Phuket (The Phuket News in Russian)", Description = "Receive one 1/2 page advertisement — 274mm (w) x 189mm (h) – in Novosti Phuket (The Phuket News in Russian), including artwork and translation.", Category = advertisingCategory, RetailPrice = 60, SponsorId = sponsors[6].Id, Sponsor = sponsors[6], OfferExpires = "January 01, 2018" }, new Item { Name = "TV Advertisement in The Phuket News TV", Description = "Receive a 1 month x 10 second fixed graphic advertisement on The Phuket News TV.", Category = advertisingCategory, RetailPrice = 60, SponsorId = sponsors[7].Id, Sponsor = sponsors[7], OfferExpires = "January 01, 2018" }, // Dining (+Accomodation +Lifestyle) new Item { Name = "Eternity Spa Package (3.5 hrs) and Set Dinner for 2 at Burasari Resort, Phuket", Description = "Enjoy an Eternity Spa Package (lasting three and a half hours) as well as a set dinner for 2 persons at the Burasari Resort in Patong, Phuket.", Category = diningCategory, RetailPrice = 60, SponsorId = sponsors[8].Id, Sponsor = sponsors[8], OfferExpires = "April 30, 2018", Terms = "Voucher is valid from 1 June 2017 – 30 April 2018. Voucher cannot be used with other discount or special promotion. Voucher cannot be exchanged for cash. Original voucher must be presented upon check-in. Advance reservations are required and subject to availability" }, new Item { Name = "THB 5,000 Voucher for use The Siam Supper Club", Description = "The winning bidder will get to enjoy THB 5,000 during a dining and/or drinking experience at The Siam Supper Club.", Category = diningCategory, RetailPrice = 60, SponsorId = sponsors[9].Id, Sponsor = sponsors[9], OfferExpires = "January 01, 2018", Terms = "Not redeemable for cash." }, // Entertainment new Item { Name = "Nuvo AccentPLUS1 6.5″ In-Ceiling Speakers", Description = "Fill the room with impeccably clean, full sound with this set of Nuvo AccentPLUS1 6.5″ In-Ceiling Speakers.", Category = entertainmentCategory, RetailPrice = 60, SponsorId = sponsors[10].Id, Sponsor = sponsors[10] }, // Lifestyle (+Dinning, + Accomodation) new Item { Name = "2 Nights Accommodation at Novotel Phuket Kamala Beach + Dinner + Spa", Description = "Enjoy a 3 day 2 night stay for two persons at the Novotel Phuket Kamala Beach in a One Bedroom Pool Villa including daily breakfast, a romantic dinner for 2 at On The Roof and a one hour spa treatment for 2.", Category = lifestyleCategory, RetailPrice = 60, SponsorId = sponsors[11].Id, Sponsor = sponsors[11], OfferExpires = "May 13, 2018", Terms = "Voucher is valid from now to 13 May 2018. Blackout dates: 1 November 2017 to 31 March 2018." }, }; foreach (Item item in items) { context.Items.Add(item); } context.SaveChanges(); // Listings var listings = new Listing[] { new Listing { MinimumBid = 20, Increment = 5, AuctionId = auctions[0].Id, ItemId = items[0].Id }, new Listing { MinimumBid = 10, Increment = 2, AuctionId = auctions[0].Id, ItemId = items[1].Id }, new Listing { MinimumBid = 10, Increment = 2, AuctionId = auctions[0].Id, ItemId = items[2].Id }, new Listing { MinimumBid = 10, Increment = 2, AuctionId = auctions[0].Id, ItemId = items[3].Id }, new Listing { MinimumBid = 10, Increment = 2, AuctionId = auctions[0].Id, ItemId = items[4].Id }, new Listing { MinimumBid = 20, Increment = 5, AuctionId = auctions[0].Id, ItemId = items[5].Id }, new Listing { MinimumBid = 10, Increment = 2, AuctionId = auctions[0].Id, ItemId = items[6].Id }, new Listing { MinimumBid = 10, Increment = 2, AuctionId = auctions[0].Id, ItemId = items[7].Id }, new Listing { MinimumBid = 10, Increment = 2, AuctionId = auctions[0].Id, ItemId = items[8].Id }, new Listing { MinimumBid = 10, Increment = 2, AuctionId = auctions[0].Id, ItemId = items[9].Id }, new Listing { MinimumBid = 10, Increment = 2, AuctionId = auctions[0].Id, ItemId = items[10].Id }, new Listing { MinimumBid = 10, Increment = 2, AuctionId = auctions[0].Id, ItemId = items[11].Id } }; foreach (Listing listing in listings) { context.Listings.Add(listing); } // User Roles var role = new Role { Id = RoleId.User, Name = "User" }; context.Roles.Add(role); role = new Role { Id = RoleId.Administrator, Name = "Administrator" }; context.Roles.Add(role); // Images // Found at: https://phab.phukethotelsassociation.com/silent-auction/ // Media types: https://en.wikipedia.org/wiki/Media_type var currentFolderPath = Assembly.GetEntryAssembly().Location; var poolVillaTisara1 = new Media { FileName = "PoolVillaTisara1.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/2017_13_02_TRISARA__1090_FINAL-1900x1267.jpg")) }; context.Media.Add(poolVillaTisara1); var poolVillaTisara2 = new Media { FileName = "poolVillaTisara2.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/H-OPV-10_Bathroom-1900x1501.jpg")) }; context.Media.Add(poolVillaTisara2); var andaraResortBBQ = new Media { FileName = "Andara18.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/Andara18.jpg")) }; context.Media.Add(andaraResortBBQ); var leMeridien = new Media { FileName = "Le-Meridien-Phuket-Beach-Resort-2-Dinners_1900x1267.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/Le-Meridien-Phuket-Beach-Resort-2-Dinners_1900x1267.jpg")) }; context.Media.Add(leMeridien); var movenpickResort = new Media { FileName = "Movenpick-Resort-Bangtao-Beach_1900x1267.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/Movenpick-Resort-Bangtao-Beach_1900x1267.jpg")) }; context.Media.Add(movenpickResort); var surinResort = new Media { FileName = "re_The-Surin-1900x1267.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/re_The-Surin-1900x1267.jpg")) }; context.Media.Add(surinResort); var novotelKamala = new Media { FileName = "novotel-kamala.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/novotel-kamala.jpg")) }; context.Media.Add(novotelKamala); var eternitySpa = new Media { FileName = "Eternity-Spa-Package_1900x1267.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/Eternity-Spa-Package_1900x1267.jpg")) }; context.Media.Add(eternitySpa); var siamSupper = new Media { FileName = "siam-supper-club_1900x1267.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/siam-supper-club_1900x1267.jpg")) }; context.Media.Add(siamSupper); var ceilingSpeaker = new Media { FileName = "AccentPLUS1-Ceiling-Speaker-AP1C_1900x1267.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/AccentPLUS1-Ceiling-Speaker-AP1C_1900x1267.jpg")) }; context.Media.Add(ceilingSpeaker); var adPhuketNewsThai = new Media { FileName = "KPK_GiftVoucher-ForKhaoPhuket_Oct-27-2017_Lowres_1900x1267.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/KPK_GiftVoucher-ForKhaoPhuket_Oct-27-2017_Lowres_1900x1267.jpg")) }; context.Media.Add(adPhuketNewsThai); var adPhuketNewsRussian = new Media { FileName = "NP_GiftVoucher-Novostia-Phuket_Oct-20-2017_Lowres_1900x1267.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/NP_GiftVoucher-Novostia-Phuket_Oct-20-2017_Lowres_1900x1267.jpg")) }; context.Media.Add(adPhuketNewsRussian); var tvAd = new Media { FileName = "TPN_GiftVoucher-ForPhuketNewsTV_Oct-27-2017_Lowres_1_1900x1267.jpg", Type = "image/jpeg", Content = File.ReadAllBytes(Path.Combine(currentFolderPath, "../../../../SampleImages/Item1/TPN_GiftVoucher-ForPhuketNewsTV_Oct-27-2017_Lowres_1_1900x1267.jpg")) }; context.Media.Add(tvAd); //context.ItemMedia.Add(new ItemMedia { Item = items[0], Media = poolVillaTisara1 }); context.ItemMedia.Add(new ItemMedia { Item = items[0], Media = poolVillaTisara2 }); context.ItemMedia.Add(new ItemMedia { Item = items[1], Media = leMeridien }); context.ItemMedia.Add(new ItemMedia { Item = items[2], Media = andaraResortBBQ }); context.ItemMedia.Add(new ItemMedia { Item = items[3], Media = surinResort }); context.ItemMedia.Add(new ItemMedia { Item = items[4], Media = movenpickResort }); context.ItemMedia.Add(new ItemMedia { Item = items[5], Media = adPhuketNewsThai }); context.ItemMedia.Add(new ItemMedia { Item = items[6], Media = adPhuketNewsRussian }); context.ItemMedia.Add(new ItemMedia { Item = items[7], Media = tvAd }); context.ItemMedia.Add(new ItemMedia { Item = items[8], Media = eternitySpa }); context.ItemMedia.Add(new ItemMedia { Item = items[9], Media = siamSupper }); context.ItemMedia.Add(new ItemMedia { Item = items[10], Media = ceilingSpeaker }); context.ItemMedia.Add(new ItemMedia { Item = items[11], Media = novotelKamala }); context.SaveChanges(); }
public ActionResult Add() { Role model = new Role(); return(View("Form", model)); }
public async Task <string> GetRoleNameAsync([FromBody] Role role) => await _RoleStore.GetRoleNameAsync(role);
public bool HasRole(string feed, Role role) { return(_roleManager.HasRole(feed, role)); }
public async Task <bool> UpdateAsync(Role role) { var uprate_result = await _RoleStore.UpdateAsync(role); return(uprate_result.Succeeded); }
public async Task <string> GetNormalizedRoleNameAsync(Role role) => await _RoleStore.GetNormalizedRoleNameAsync(role);
public IRole CreateRole() { var result = new Role(); return(result); }
public async Task <bool> DeleteAsync(Role role) { var delete_result = await _RoleStore.DeleteAsync(role); return(delete_result.Succeeded); }
void SaveModules() { if (!string.IsNullOrEmpty(txtGroupName.Text.Trim())) { try { Role role = Global.Core.Roles.GetSingle("Name", txtGroupName.Text.Trim()); if (role != null) { Response.Redirect("CreateGroup.aspx" + "?error=3", false); } else { Role newrole = new Role(Global.Core.Roles) { Id = Guid.NewGuid(), Name = txtGroupName.Text.Trim(), Description = txtGroupName.Text.Trim() }; newrole.Insert(); foreach (PermissionCore.Classes.Section sec in Global.PermissionCore.Sections.Items) { foreach (PermissionCore.Classes.Permission permission in sec.Permissions) { var cntrl = pnlModuleDetails.FindControl("tbl" + sec.Name) .FindControl("chk_" + permission.Id); var tblCntrl = cntrl is WebUtilities.Controls.CheckBox ? (WebUtilities.Controls.CheckBox)cntrl : null; if (tblCntrl != null) { RolePermission rolepermission = Global.Core.RolePermissions.GetSingle(new string[] { "IdRole", "Permission" }, new object[] { newrole.Id, permission.Id }); if (rolepermission == null && tblCntrl.Checked) { rolepermission = new RolePermission(Global.Core.RolePermissions); rolepermission.Permission = permission.Id; rolepermission.IdRole = newrole.Id; rolepermission.Insert(); } else if (rolepermission != null && tblCntrl.Checked == false) { Global.Core.RolePermissions.Delete(rolepermission.Id); } } } } Response.Redirect("CreateGroup.aspx" + "?error=1", false); } } catch (Exception ex) { HttpContext.Current.Session["Error"] = ex.Message; Response.Redirect("CreateGroup.aspx" + "?error=2", false); } } }
private async Task PrepareContent() { var adminRole = new Role { Name = "admin", NormalizedName = "ADMIN" }; var userRole = new Role { Name = "user", NormalizedName = "USER" }; await this.context.Roles.AddRangeAsync(adminRole, userRole); await this.context.SaveChangesAsync(); var rootUser = new User { UserName = "******", Email = "*****@*****.**", PhoneNumber = "0 888 888 888", RegisteredOn = DateTime.UtcNow, }; var admin = new User { UserName = "******", Email = "*****@*****.**", PhoneNumber = "0 888 888 888", RegisteredOn = DateTime.UtcNow, }; var user = new User { UserName = "******", Email = "*****@*****.**", PhoneNumber = "0 888 888 888", RegisteredOn = DateTime.UtcNow, }; await this.context.Users.AddRangeAsync(rootUser, admin, user); await this.context.SaveChangesAsync(); await this.context.UserRoles.AddAsync(new IdentityUserRole<string> { RoleId = adminRole.Id, UserId = rootUser.Id, }); await this.context.UserRoles.AddAsync(new IdentityUserRole<string> { RoleId = adminRole.Id, UserId = admin.Id, }); await this.context.UserRoles.AddAsync(new IdentityUserRole<string> { RoleId = userRole.Id, UserId = user.Id, }); await this.context.SaveChangesAsync(); }
private void dataGridView1_SelectionChanged(object sender, EventArgs e) { this.skinTreeViewPermisson.AfterCheck -= this.skinTreeViewPermisson_AfterCheck; DataGridView view = sender as DataGridView; if (view.CurrentRow != null) { user = view.CurrentRow.DataBoundItem as Role; } if (user == null) { return; } skinTextBoxRoleName.Text = user.Name; textBoxRemark.Text = user.Remarks; if (SystemDefault.DefaultAdminRole == user.AutoID) { skinSplitContainer1.Panel2.Enabled = false; } else { skinSplitContainer1.Panel2.Enabled = true; } ResetNodeCheck(false); List <int> permissions = null; try { if (CommonGlobalUtil.EngineUnconnectioned(this)) { return; } InteractResult <List <int> > result = GlobalCache.ServerProxy.GetRolePermissions4RoleID(user.AutoID); permissions = result.Data; } catch (Exception ex) { // GlobalUtil.ShowError(ex); } finally { UnLockPage(); } if (permissions == null) { ResetNodeCheck(true); } else if (permissions.Count == 0) { ResetNodeCheck(false); } else { // String[] permissions = permission.Split(','); foreach (var item in permissions) { ResetNodeFullPathCheck(item, true); } } skinTreeViewPermisson.Refresh(); this.skinTreeViewPermisson.AfterCheck += this.skinTreeViewPermisson_AfterCheck; }
public async Task InitializeAsync() { await _context.Database.MigrateAsync(); var user1 = new User { FirstName = "Admin", LastName = "Exoft", Email = "*****@*****.**", UserName = "******", XP = 30, Password = _passwordHasher.GetHash("Pa$$word123"), Status = "Status bla bla bla" }; var user2 = new User { FirstName = "Tanya", LastName = "Gogina", Email = "*****@*****.**", UserName = "******", XP = 40, Password = _passwordHasher.GetHash("Pa$$word123"), Status = "Status 123" }; var user3 = new User { FirstName = "Ostap", LastName = "Roik", Email = "*****@*****.**", UserName = "******", XP = 0, Password = _passwordHasher.GetHash("Pa$$word123"), Status = "Status 123" }; var achievement1 = new Achievement { Name = "Welcome", Description = "A newcomer to the team", XP = 10 }; var achievement2 = new Achievement { Name = "1 year", Description = "1 year in company", XP = 30 }; var role1 = new Role { Name = "Admin" }; var role2 = new Role { Name = "User" }; var event1 = new Event { Description = "First", Type = GamificationEnums.EventType.Race, User = user1 }; var event2 = new Event { Description = "Second", Type = GamificationEnums.EventType.Records, User = user1 }; var event3 = new Event { Description = "Third", Type = GamificationEnums.EventType.Upload, User = user2 }; if (!await _context.Users.AnyAsync()) { await _context.Users.AddAsync(user1); await _context.Users.AddAsync(user2); await _context.SaveChangesAsync(); } if (!await _context.Achievements.AnyAsync()) { await _context.Achievements.AddAsync(achievement1); await _context.Achievements.AddAsync(achievement2); await _context.SaveChangesAsync(); } if (!await _context.Roles.AnyAsync()) { await _context.Roles.AddAsync(role1); await _context.Roles.AddAsync(role2); await _context.SaveChangesAsync(); } if (!await _context.UserAchievement.AnyAsync()) { await _context.UserAchievement.AddAsync(new UserAchievement { User = user1, Achievement = achievement2 }); await _context.UserAchievement.AddAsync(new UserAchievement { User = user2, Achievement = achievement1 }); await _context.UserAchievement.AddAsync(new UserAchievement { User = user2, Achievement = achievement2 }); await _context.SaveChangesAsync(); } if (!await _context.UserRoles.AnyAsync()) { await _context.UserRoles.AddAsync(new UserRoles { User = user1, Role = role1 }); await _context.UserRoles.AddAsync(new UserRoles { User = user2, Role = role2 }); await _context.UserRoles.AddAsync(new UserRoles { User = user3, Role = role2 }); await _context.SaveChangesAsync(); } if (!await _context.Events.AnyAsync()) { await _context.Events.AddAsync(event1); await _context.Events.AddAsync(event2); await _context.Events.AddAsync(event3); await _context.SaveChangesAsync(); } if (!await _context.Categories.AnyAsync()) { var bytes = Convert.FromBase64String( "iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAYAAADG4PRLAAAABHNCSVQICAgIfAhkiAAAEBxJRE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iRzAfseeG6C43MasBcJqiO4lHIvmqB54zX3Vpor7JQtLevSjT0Jy+ma75gfVwmoh5Cj6RXKDxZu3TjG2GXGdmM3KHWayozvU6DYjYBuumKRPbDc5f/sj+q8sYSB1+4PDmu+px618Qq/LQGsseOHW1Y0fLRaNtVZgzyf4xWQBXSeotUAAAAAElFTkSuQmCC"); var file = new File { ContentType = "image/png", Data = bytes }; await _context.Files.AddAsync(file); await _context.SaveChangesAsync(); await _context.Categories.AddRangeAsync(new List <Category> { new Category { Name = "Apple", IconId = file.Id }, new Category { Name = "Android", IconId = file.Id }, new Category { Name = "Health", IconId = file.Id }, new Category { Name = "Food", IconId = file.Id }, new Category { Name = "Man", IconId = file.Id }, new Category { Name = "Woman", IconId = file.Id }, new Category { Name = "Car", IconId = file.Id }, new Category { Name = "Sport", IconId = file.Id }, new Category { Name = "Games", IconId = file.Id }, new Category { Name = "Puzzle", IconId = file.Id }, new Category { Name = "Animal", IconId = file.Id }, new Category { Name = "Steam", IconId = file.Id } }); await _context.SaveChangesAsync(); } }