public string UserData(FormCollection fc) { // instantiate a serializer JavaScriptSerializer TheSerializer = new JavaScriptSerializer(); if (!User.Identity.IsAuthenticated) { return(TheSerializer.Serialize(new { noAuth = "NoAuthrezited" })); } string userName = fc["FullName"]; using (UserM user = new UserM()) { var userData = user.SearchFor(u => u.FullName == userName).FirstOrDefault(); if (userData.Image == null) { string path = Server.MapPath("~/Images/Logos/noPhoto.jpg"); FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); userData.Image = new byte[(int)fileStream.Length]; fileStream.Read(userData.Image, 0, userData.Image.Length); } var TheJson = TheSerializer.Serialize(new { Email = userData.Email, IdNumber = userData.IdNumber, Image = userData.Image, id = userData.id, } ); return(TheJson); } }
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e) { if (FormsAuthentication.CookiesSupported == true) { if (Request.Cookies[FormsAuthentication.FormsCookieName] != null) { try { //let us take out the username now string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name; string roles = string.Empty; using (UserM entities = new UserM()) { var user = entities.SearchFor(u => u.FullName == username).First(); roles = user.Role; } //let us extract the roles from our own custom cookie //Let us set the Pricipal with our user specific details HttpContext.Current.User = new System.Security.Principal.GenericPrincipal( new System.Security.Principal.GenericIdentity(username, "Forms"), roles.Split(';')); } catch (Exception es) { var s = es.Message; } } } }
/// <summary> /// get details /// </summary> /// <param name="id">user id</param> /// <returns></returns> // GET: User/Details/5 public ActionResult Details(int id) { using (UserM user = new UserM()) { return(View(user.GetById(id))); } }
public async void DeleteUserWorksAgain() { DbContextOptions <ColorSchemeDbContext> options = new DbContextOptionsBuilder <ColorSchemeDbContext> ().UseInMemoryDatabase("DeleteUser").Options; using (ColorSchemeDbContext context = new ColorSchemeDbContext(options)) { // arrange UserM user = new UserM(); user.ID = 2; user.Name = "Jennifer"; UserService service = new UserService(context); await service.CreateUser(user); // Act await service.DeleteUser(2); var deleted = context.User.FirstOrDefault(u => u.ID == user.ID); // Assert Assert.Null(deleted); } }
/// <summary> /// getting all peoples fom data base /// </summary> /// <returns>view with people list</returns> // GET: User public ActionResult Index() { using (UserM user = new UserM()) { return(View(user.GetAll().ToList())); } }
/// <summary> /// 炮弹兵是否能增加经验 0:可以增加,1:已经满级不能增加 /// </summary> /// <returns><c>true</c>, if can add exp was checked, <c>false</c> otherwise.</returns> /// <param name="SoldireTypeID">炮弹兵ID.</param> /// <param name="AddExpNum">炮弹兵增加的经验值</param> public static int CheckCanAddExp(int SoldireTypeID, int AddExpNum) { SoldierInfo info = SoldierDC.GetSoldiers(SoldireTypeID); if (info == null) { return(0); } s_soldier_experienceInfo expInfo = GetSoldierExpData(info.Level); if (expInfo.exp == 0) { return(1); } int MaxLvl = UserM.GetUserMaxHeroLevel(info.Level); int MaxExp = GetSoldierTotalExpAtLevel(MaxLvl); if (info.EXP >= MaxExp) { return(1); } else if (info.EXP + AddExpNum < MaxExp) { return(0); } else if (info.EXP + AddExpNum > MaxExp && info.EXP < MaxExp) { return(0); } return(0); }
/// <summary> /// 吃经验. /// </summary> /// <param name="Num">Number.</param> private void AddItemUseNum(int Num) { m_parent.SetItemNum(); m_iHaveAddNum = m_iHaveAddNum + Num; if (!MyHead.LblNumUsed.gameObject.activeInHierarchy) { MyHead.LblNumUsed.gameObject.SetActive(true); } MyHead.LblNumUsed.text = "X" + m_iHaveAddNum.ToString(); int MaxLvl = UserM.GetUserMaxHeroLevel(UserDC.GetLevel()); Info.EXP += int.Parse(m_ItemInfo.m_args); int MaxExp = SoldierM.GetSoldierTotalExpAtLevel(MaxLvl); int LevExp = SoldierM.GetSoldierExp(Info.Level); if (Info.EXP >= LevExp && Info.Level < MaxLvl) { int exp = SoldierM.GetSoldierExp(Info.Level); CalUplevelNum(exp, MaxLvl); } int Exp = SoldierM.GetSoldierExp(Info.Level); float pre = (Info.EXP * 1.0f) / (Exp * 1.0f); AddLeveAndExp(Info.Level, pre, true); }
private void registerUser() { if (checkIfHasValidationErrors() == false) { UserM rm = new UserM(); rm.fullname = this.fullname; rm.username = this.username; rm.email = this.email; rm.password = this.password; rm.addUser(); if (rm.response == "500") { errList.Add("Server Error!"); } else { errList.Add(""); } } else { errList.Add(""); } }
public async void UpdateUserWorksAgain() { DbContextOptions <ColorSchemeDbContext> options = new DbContextOptionsBuilder <ColorSchemeDbContext> ().UseInMemoryDatabase("UpdateUser").Options; using (ColorSchemeDbContext context = new ColorSchemeDbContext(options)) { // arrange UserM user = new UserM(); user.ID = 3; user.Name = "Jason"; UserService service = new UserService(context); await service.CreateUser(user); // Act user.Name = "Tom"; await service.Updateuser(user); // Assert Assert.Equal("Tom", user.Name); } }
public bool ShowCaptionUpWnd() { CombatScene combat = SceneM.GetCurIScene() as CombatScene; if (combat != null) { UserInfo old = combat.m_oldUserInfo; if (old.Level < UserDC.GetLevel()) { CaptionUpgradeWnd cuw = WndManager.GetDialog <CaptionUpgradeWnd>(); int oldMaxPhysical = UserM.GetMaxPhysical(old.Level); int newMaxPhysical = UserM.GetMaxPhysical(UserDC.GetLevel()); int oldMaxherolevel = UserM.GetUserMaxHeroLevel(old.Level); int newMaxherolevel = UserM.GetUserMaxHeroLevel(UserDC.GetLevel()); cuw.SetData(old.Level, UserDC.GetLevel(), StageDC.GetStageResult().win ? old.Physical - StageDC.GetCounterPartInfo().win_physical : old.Physical - StageDC.GetCounterPartInfo().lose_physical, UserDC.GetPhysical(), oldMaxPhysical, newMaxPhysical, oldMaxherolevel, newMaxherolevel); cuw.MyHead.BtnBg.OnClickEventHandler += BackMainScence; cuw.MyHead.BtnClose.OnClickEventHandler += BackMainScence; return(true); } } return(false); }
void RefreshUI() { int currentPhysics = UserDC.GetPhysical(); int total = UserM.GetMaxPhysical(UserDC.GetLevel()); if (currentPhysics >= total) { SetType(0); } else { SetType(1); } int serverTime = GlobalTimer.GetNowTimeInt(); NGUIUtil.SetLableText <string>(MyHead.LblTime, NdUtil.ConvertServerTime(serverTime)); if (m_iType == 1) { int resumePhysicsTime = GlobalTimer.instance.GetPhysicsResumeCounter(); NGUIUtil.SetLableText <string>(MyHead.LblNextResumeTime, NdUtil.TimeFormat(resumePhysicsTime)); int resumePhysicsAllTime = GlobalTimer.instance.GetPhysicsResumeAllCounter(); NGUIUtil.SetLableText <string>(MyHead.LblResumeAllTime, NdUtil.TimeFormat(resumePhysicsAllTime)); } }
public UserM GetUser(string userID) { UserDA userDA = null; DataRow dr; var u = new UserM { }; try { userDA = new UserDA(); dr = userDA.GetUsers(userID).Rows[0]; u = new UserM { UserID = dr["UserID"].ToString(), UserName = dr["UserName"].ToString(), Active = CommUtil.ConvertObjectToBool(dr["Active"]), IsDeleted = Convert.ToByte(dr["IsDeleted"]), }; } finally { if (userDA != null) { userDA.CloseConnection(); } } return(u); }
public ActionResult New(UserM model) { if (ModelState.IsValid) { try { var result = userBL(true).New(model); if (result.IsSuccess && result.Affected > 0) { return(RedirectToAction("List", "User")); } else { ModelState.AddModelError("ErrorMessage", result.Exception); } } catch (Exception ex) { ModelState.AddModelError("ErrorMessage", ex.Message); } } else { var e = ModelState.Where(z => z.Key == string.Empty && z.Value.Errors != null); if (e.Count() > 0) { ModelState.AddModelError("ErrorMessage", e.First().Value.Errors.First().ErrorMessage); } } return(View(model)); }
public ActionResult Index(UserM objUsr) { // email not verified on registration time objUsr.EmailVerification = false; //it generate unique code //Email Exist or Not var IsExists = IsEmailExists(objUsr.Email); if (IsExists) { ModelState.AddModelError("EmailExists", "Email Already Exists"); return(View("Registration")); } objUsr.ActivetionCode = Guid.NewGuid(); //password convert objUsr.Password = UserLogin.Models.encryptPassword.textToEncrypt(objUsr.Password); objCon.UserMs.Add(objUsr); objCon.SaveChanges(); //Send Email Verification Link SendEmailToUser(objUsr.Email, objUsr.ActivetionCode.ToString()); var Message = "Registration Completed. Please Check your Email: " + objUsr.Email; ViewBag.Message = Message; return(View("Registration")); }
public AddNew(MainForm form, UserM user) { forms = form; _user = user; InitializeComponent(); CenterToScreen(); setYear(); comboYear.Items.AddRange(new object[] { intYear, intYear + 1, intYear + 2, intYear + 3, intYear + 4, intYear + 5, intYear + 6, intYear + 7, intYear + 8, }); comboYear.Text = intYear.ToString(); comboMonth.Text = months; }
public List <CheckPermission> GetPermissionAsBool(UserM user) { List <CheckPermission> Lcps = new List <CheckPermission>(); DataTable dt = GetDataTable("select * from " + TABLE_NAME + "where " + RULE_ID + "='" + user.Rule_id + "'"); System.Windows.Forms.MessageBox.Show("fixme"); return(Lcps); }
public void demo_insertlist12() { DataList list = new DataList(); UserM tb = new UserM(); tb.insertList(list.getRows()); }
public string getUserId() { UserM um = new UserM(); um.username = this.username; um = um.getUserByUsername(); return(um.user_id); }
public int GetPhysicsResumeAllCounter() { int current = UserDC.GetPhysical(); int total = UserM.GetMaxPhysical(UserDC.GetLevel()); int temp = (total - current - 1) * ConfigM.GetResumePhysicsTime(); return(PhysicsResumeCounter + temp); }
public IActionResult Record(UserM userM) { if (ModelState.IsValid) { userM.recordName(); return(RedirectToAction("name has been saved")); } return(View()); }
public ActionResult Index(User model) { if (model.vEmail != null && model.vPassword != null) { UserM userInfo = objLogin.getUserInfo(model.vEmail, model.vPassword); return(RedirectToAction("Index", "Home", new { userName = userInfo.vName, uid = userInfo.iID.ToString(), status = userInfo.vStatus, designation = userInfo.vDesignation })); } return(View(model)); }
protected void Page_Load(object sender, System.EventArgs e) { try { // grab CourseID parameter from the querystring AssignmentManager.Common.Functions func = new AssignmentManager.Common.Functions(); courseId = func.ValidateNumericQueryStringParameter(this.Request, "CourseID"); UserM user = UserM.Load(SharedSupport.GetUserIdentity()); if (!user.IsInCourse(courseId)) { Response.Redirect(@"../Error.aspx?ErrorDetail=" + "Global_Unauthorized"); } Nav1.Feedback.Text = String.Empty; Nav1.SideTabId = AssignmentManager.Common.constants.SIDE_NAV_STUDENT_CHANGE_PASSWORD; Nav1.TopTabId = AssignmentManager.Common.constants.TOP_NAV_STUDENT_CHANGE_PASSWORD; Nav1.Title = SharedSupport.GetLocalizedString("ChangePassword_Title1"); Nav1.SubTitle = SharedSupport.GetLocalizedString("ChangePassword_SubTitle1"); Nav1.relativeURL = @"../"; //GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("vstskChangingYourUserPassword"); GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("tskChangingYourUserPasswordForAssignmentManager"); GoBack1.GoBack_left = "275px"; GoBack1.GoBack_top = "-15px"; GoBack1.GoBackIncludeBack = false; if (courseId <= 0) { throw(new ArgumentException(SharedSupport.GetLocalizedString("Global_MissingParameter"))); } // if using SSL and the page isn't using a secure connection, redirect to https if (SharedSupport.UsingSsl == true && Request.IsSecureConnection == false) { // Note that Redirect ends page execution. Response.Redirect("https://" + SharedSupport.BaseUrl + "/faculty/ChangePassword.aspx?CourseID=" + courseId.ToString()); } if (!IsPostBack) { // Evals true first time browser hits the page LocalizeLabels(); } Response.Cache.SetNoStore(); if (user.IsValid) { this.lblUserName.Text = Server.HtmlEncode(user.FirstName + " " + user.LastName); } } catch (Exception ex) { Nav1.Feedback.Text = ex.Message.ToString(); } }
public async Task <IActionResult> Create([Bind("ID,Name")] UserM user) { if (ModelState.IsValid) { await _context.CreateUser(user); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public void GetUserPropertiesWork() { //Arrange UserM user = new UserM(); user.ID = 1; //Assert Assert.Equal(1, user.ID); }
/// <summary> /// /// </summary> /// <param name="us"></param> /// <param name="selectednode">name of node in treeview </param> /// <returns></returns> public bool Update(UserM us, string selectednode) { if (!IsExecute(Update(TABLE_NAME, new string[] { USERNAME + "='" + us.UserName + "'", NAME + "='" + us.Name + "'", PHONE + "='" + us.Phone + "'", EMAIL + "='" + us.Email + "'", RULE_ID + "='" + us.Rule_id + "'" }, USERNAME + "='" + selectednode + "'"))) { System.Windows.Forms.MessageBox.Show("Error When Update User In 'user' Table"); return(false); } return(true); }
public bool UpdatePassword(UserM user) { user.Password = crypt.MD5Hash(user.Password); if (!IsExecute(Update(TABLE_NAME, new string[] { PASSWORD + "='" + user.Password + "'" }, ID + "='" + user.Id + "'"))) { Debug.WriteLine("Error When Update Password"); return(false); } return(true); }
public void GetUserPropertiesWorkAgain() { //Arrange UserM user = new UserM(); user.ID = 1; user.Name = "jason"; //Assert Assert.Equal("jason", user.Name); }
/// <summary> /// /// </summary> /// <param name="ds"> </param> private void populateFields(UserM user) { if (user.EmailAddress != null && user.EmailAddress != String.Empty) { txtEMailAddress.Text = user.EmailAddress; } if (user.FirstName != null && user.FirstName != String.Empty) { txtFirstName.Text = user.FirstName; } if (user.LastName != null && user.LastName != String.Empty) { txtLastName.Text = user.LastName; } if (user.MiddleName != null && user.MiddleName != String.Empty) { txtMiddleName.Text = user.MiddleName; } if (user.UniversityID != null && user.UniversityID != String.Empty) { txtUniversityIdentifier.Text = user.UniversityID; } if (user.UserName != null && user.UserName != "") { txtUserName.Text = user.UserName; } //Set current role RoleM role = user.GetRoleInCourse(courseId); for (int i = 0; i < UserRolesList.Items.Count; i++) { if (UserRolesList.Items[i].Value == role.ID.ToString()) { UserRolesList.SelectedIndex = i; break; } } if (role.ID > 0) { RoleM currentUsersRole = RoleM.GetUsersRoleInCourse(SharedSupport.GetUserIdentity(), courseId); //Note: Can't change the role of someone = in level to you. if ((currentUsersRole.ID > (int)PermissionsID.Admin) && (currentUsersRole.ID >= role.ID)) { UserRolesList.Enabled = false; } } }
public UserPanel(UserM user) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); CenterToScreen(); lbusername.Text = user.UserName; // // TODO: Add constructor code after the InitializeComponent() call. // }
public ActionResult <UserM> GetUserByID(int id) { var userDB = UserManager.UserById(id); var Result = new UserM() { User_Id = userDB.Id, FirstName = userDB.FirstName, LastName = userDB.LastName }; return(Result); }