public RecommendedUserDto(GeneralUser user) { Id = user.Id; Name = user.GetName(); Location = user.Location; Interests = String.Join(", ", user.Interests.Select(x => x.Foi.Name).ToList()); }
/// <summary> /// 加载导航目录树 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GeneralUser user = Session["UserInfo"] as GeneralUser; //获取用户信息 if (user.RoleInfo.Id == UserRoleConst.Author) { //登录用户是作者 this.trvNav.DataSource = this.AuthorXmlDataSource; this.DataBind(); } else if (user.RoleInfo.Id == UserRoleConst.LayoutEditor) //排版编辑 { this.trvNav.DataSource = this.LayoutXmlDataSource; this.DataBind(); } else if (user.RoleInfo.Id == UserRoleConst.ResponsibleEditor) //责任编辑 { this.trvNav.DataSource = this.ResponsibleXmlDataSource; this.DataBind(); } else { this.trvNav.DataSource = this.UserWorkXmlDataSource; this.DataBind(); } } }
public async Task<IActionResult> OnPostConfirmationAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); // Get the information about the user from the external login provider var info = await _signInManager.GetExternalLoginInfoAsync(); if (info == null) { ErrorMessage = "Error loading external login information during confirmation."; return RedirectToPage("./Login", new { ReturnUrl = returnUrl }); } if (ModelState.IsValid) { var user = new GeneralUser { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user); if (result.Succeeded) { result = await _userManager.AddLoginAsync(user, info); if (result.Succeeded) { await _signInManager.SignInAsync(user, isPersistent: false); _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider); return LocalRedirect(returnUrl); } } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } LoginProvider = info.LoginProvider; ReturnUrl = returnUrl; return Page(); }
/// <summary> /// 提交修改信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { GeneralUser user = Session["UserInfo"] as GeneralUser; //获取用户基本信息 user.Tel = this.txtTel.Value; user.RealName = this.txtRealName.Value; user.Birthday = Convert.ToDateTime(this.txtBirthday.Value); user.Email = this.txtEMail.Value; if (ddlSex.SelectedValue == "1") { user.Sex = true; } else { user.Sex = false; } if (UserManager.UpdateGeneralUserInfo(user) > 0) { //更新成功 ClientScript.RegisterStartupScript(GetType(), "Update Success", "alert('更新成功!')", true); } else { ClientScript.RegisterStartupScript(GetType(), "Update Success", "alert('更新失败!')", true); } }
// GET: Interests public ActionResult Index() { GeneralUser user = db.Users.Include(i => i.Interests).FirstOrDefault(u => u.Email == User.Identity.Name); IList <UserFOI> result = user != null ? user.Interests : new List <UserFOI>(); return(View(result)); }
public async Task CreateBuddyRequestAsync(int requestingGeneralUserId, int receivingGeneralUserId) { // Validate GeneralUsers if (requestingGeneralUserId == receivingGeneralUserId) { throw new ArgumentException("Requesting and Receiving GeneralUserId cannot be the same."); } GeneralUser requestingGeneralUser = _databaseContext.GeneralUsers.SingleOrDefault(g => g.Id == requestingGeneralUserId) ?? throw new ArgumentException($"GeneralUser ID: {requestingGeneralUserId} could not be found."); GeneralUser receivingGeneralUser = _databaseContext.GeneralUsers.SingleOrDefault(g => g.Id == receivingGeneralUserId) ?? throw new ArgumentException($"GeneralUser ID: {receivingGeneralUserId} could not be found."); if (IsExistingBuddyRequest(requestingGeneralUserId, receivingGeneralUserId)) { throw new ArgumentException($"A buddy request already exists for GeneralUser {requestingGeneralUserId} and {receivingGeneralUserId}."); } // Save to db _databaseContext.BuddyRequests.Add(new BuddyRequest() { ReceivingGeneralUser = receivingGeneralUser, RequestingGeneralUser = requestingGeneralUser, RequestState = BuddyRequestState.Pending }); await _databaseContext.SaveChangesAsync(); }
public async Task <IActionResult> Edit(string id, [Bind("ID,FirstName,LastName,Email,Password,CreditCard,CarNumber,CarType,Address,PhoneNumber,Balance")] GeneralUser generalUser) { if (id != generalUser.UID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(generalUser); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GeneralUserExists(generalUser.UID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(generalUser)); }
public void Case06() { GeneralUser user2 = new GeneralUser { AccountName = "User02", Domain = _domain21, Name = "user02", AuthenticateWhenUnlockingScreen = true }; UserGroupEndUser userGroupEndUser = new UserGroupEndUser() { UserGroup = _userGroup2, EndUser = user2 }; _context.AddRange(user2); _context.AddRange(userGroupEndUser); _context.SaveChanges(); var token = Utils.GetAccessToken(_client, "user1", "user1", 1, "domain"); // ユーザー管理者 var obj = new { AuthenticateWhenUnlockingScreen = false }; var result = Utils.Put(_client, $"{Url}/{user2.Id}", Utils.CreateJsonContent(obj), token); var body = result.Content.ReadAsStringAsync().Result; var json = JObject.Parse(body); Assert.Equal(HttpStatusCode.Forbidden, result.StatusCode); Assert.NotNull(json["traceId"]); Assert.NotNull(json["errors"]["Role"]); }
public void Case01() { GeneralUser user = new GeneralUser { AccountName = "User03", Domain = _domain, Name = "user03", AuthenticateWhenUnlockingScreen = true }; UserGroupEndUser userGroupEndUser = new UserGroupEndUser() { UserGroup = _userGroup1, EndUser = user }; _context.Add(user); _context.AddRange(userGroupEndUser); _context.SaveChanges(); var token = Utils.GetAccessToken(_client, "user1", "user1", 1, "domain"); // ユーザー管理者 var obj = new { AuthenticateWhenUnlockingScreen = false }; var result = Utils.Put(_client, $"{Url}/", Utils.CreateJsonContent(obj), token); var body = result.Content.ReadAsStringAsync().Result; Assert.Equal(HttpStatusCode.Forbidden, result.StatusCode); Assert.Empty(body); }
/// <summary> /// 响应责编完成按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void OnFinishResponsible(object sender, EventArgs e) { //获取基础信息 GeneralUser userResponsible = new GeneralUser(); this.GetGeneralInfo(userResponsible); //添加责编到库 if ((userResponsible.Id = UserManager.InsertGeneralUserReturnIndentity(userResponsible)) != 0) { //更新栏目 for (int i = 0; i < this.CBLArticleColumn.Items.Count; i++) { if (this.CBLArticleColumn.Items[i].Selected) { //搜出栏目 对象 int columnId = Convert.ToInt32(this.CBLArticleColumn.Items[i].Value); ArticleColumn articleColumn = ArticleColumnManager.GetArticleColumnById(columnId); //更新栏目对应责编 articleColumn.ResponsibelUserId = userResponsible.Id; articleColumn.UserInfo_Name = userResponsible.Name; ArticleColumnManager.UpdateArticleColumn(articleColumn); } } } else { return; } //显示成功页面 this.HideAllPanel(); this.PanelSuccess.Visible = true; }
public async Task CreateFavoriteLinkForUserAsync(ILink link, IGeneralUser user) { // Validate Link Link toBeCreatedFavoriteLink = _dbContext.Links.SingleOrDefault(l => l.Id == link.Id && l.IsDeleted == false ) ?? throw new ArgumentException($"Link ID: {link.Id} could not be found."); GeneralUser generalUser = _dbContext.GeneralUsers.SingleOrDefault(g => g.Id == user.Id) ?? throw new ArgumentException($"GeneralUser ID: {user.Id} could not be found."); if (toBeCreatedFavoriteLink.GeneralUserId == generalUser.Id) { throw new ArgumentException("Link belong to the logged in user."); } if (CheckExistingFavoriteLinkAysnc(toBeCreatedFavoriteLink.Id, generalUser.Id) != default) { throw new ArgumentException($"Favorite link already exists."); } // Save to db FavoriteLink newFavoriteLink = new FavoriteLink { Link = toBeCreatedFavoriteLink, GeneralUser = generalUser }; generalUser.FavoriteLinks.Add(newFavoriteLink); await _dbContext.SaveChangesAsync(); }
public void Case05() { GeneralUser user = new GeneralUser { AccountName = "User03", Domain = _domain11, Name = "User03", AuthenticateWhenUnlockingScreen = true }; UserGroupEndUser userGroupEndUser = new UserGroupEndUser() { UserGroup = _userGroup1, EndUser = user }; _context.Add(user); _context.Add(userGroupEndUser); _context.SaveChanges(); var token = Utils.GetAccessToken(_client, "user0", "user0"); // スーパー管理者 var obj = new { AuthenticateWhenUnlockingScreen = "string" }; var result = Utils.Put(_client, $"{Url}/" + user.Id, Utils.CreateJsonContent(obj), token); var body = result.Content.ReadAsStringAsync().Result; var json = JObject.Parse(body); Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode); Assert.NotNull(json["traceId"]); Assert.NotNull(json["errors"]?["AuthenticateWhenUnlockingScreen"]); }
/// <summary> /// 单击删除相应函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { //int rowindex = ((GridViewRow) (((LinkButton)sender).NamingContainer) ).RowIndex; //int UserID = Convert.ToInt32(gvUserList.DataKeys[rowindex].Value); //this.Response.Write(UserID.ToString()); //ClientScript.RegisterStartupScript(GetType(), "User Name or Password Error", "alert('不正确!')", true) LinkButton lbBtn = sender as LinkButton; int userID = Convert.ToInt32(lbBtn.CommandArgument); GeneralUser user = UserManager.GetGeneralUserInfoById(userID); if (user.RoleInfo.Id == UserRoleConst.Expert) { if (UserManager.DeleteUserExpert(userID) == 0) { ClientScript.RegisterStartupScript(GetType(), "", "alert('删除专家出错!')", true); } } else { if (UserManager.DeleteUser(userID) == 0) { ClientScript.RegisterStartupScript(GetType(), "", "alert('删除用户出错!')", true); } } thisDataBind(); }
private async Task <GeneralUser> CreateUserAsync(string email, UserManager <GeneralUser> userManager) { KeePark.Areas.Identity.Pages.Account.RegisterModel.InputModel model = new KeePark.Areas.Identity.Pages.Account.RegisterModel.InputModel { UID = "326680978", FirstName = "Peter", LastName = "Parker", PhoneNumber = "0547654332", CarNumber = "2367892", CarType = "bmw", CreditCard = "23466783", Balance = 900, ConfirmPassword = "******", Password = "******", Email = email, Address = "New York" }; var user = new GeneralUser { UserName = model.Email, Email = model.Email, Address = model.Address, Balance = model.Balance, CarNumber = model.CarNumber, CarType = model.CarType, CreditCard = model.CreditCard, FirstName = model.FirstName, LastName = model.LastName, UID = model.UID, History = "5,5,5,6,8,8,8,10" }; //var s=new KeePark. var result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { return(user); } return(null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //填充用户信息 GeneralUser user = Session["UserInfo"] as GeneralUser; //获取用户信息 this.lblID.Text = user.Id.ToString(); this.lblLoginName.Text = user.Name; this.lblRole.Text = user.RoleInfo.Name; this.txtTel.Value = user.Tel; this.txtRealName.Value = user.RealName; this.lblCreateTime.Text = user.CreateTime.Year.ToString() + '/' + user.CreateTime.Month.ToString() + '/' + user.CreateTime.Day.ToString(); this.txtBirthday.Value = user.Birthday.Year.ToString() + '/' + user.Birthday.Month.ToString() + '/' + user.Birthday.Day.ToString(); this.txtEMail.Value = user.Email; if (user.Sex) { ddlSex.SelectedValue = "1"; } else { ddlSex.SelectedValue = "0"; } } }
public void CreateUser6(SimDevice simDevice) { var admin = new AdminUser { Domain = _userGroup.Domain, UserGroup = _userGroup, Name = "管理人一郎", Password = "******", AccountName = "AccountUser1" }; var general = new GeneralUser { Domain = _userGroup.Domain, UserGroup = _userGroup, Name = "一般一郎", AccountName = "AccountUser2" }; var factorCombination = new FactorCombination { SimDevice = simDevice, EndUser = admin, StartDay = DateTime.Now.AddHours(-6.00), EndDay = DateTime.Now.AddHours(6.00), NwIpAddress = "NwAddress" }; _mainDbContext.AddRange(general, admin, factorCombination); _mainDbContext.SaveChanges(); }
private void CreateUserRecords() { var userGroup = new UserGroup() { Domain = Domain, Name = "UserGroup", AdObjectId = Guid.NewGuid() }; GeneralUser1 = new GeneralUser() { AccountName = "GeneralUser1", Name = "GU1", Domain = Domain, AuthenticateWhenUnlockingScreen = true, AdObjectId = Guid.NewGuid() }; var availablePeriod = new AvailablePeriod() { EndUser = GeneralUser1, StartDate = CurrentDateTimeForStart.Item1, EndDate = CurrentDateTimeForStart.Item2 }; var userGroupEndUser = new UserGroupEndUser() { UserGroup = userGroup, EndUser = GeneralUser1 }; MainDbContext.AddRange(userGroup, GeneralUser1, availablePeriod, userGroupEndUser); }
public async Task <IActionResult> ServiceBookingPage(int id) { if (User.Identity.IsAuthenticated) { GeneralUser user = await GetCurrentUserAsync(); Payment payment = repository.Payments.Where(p => p.UserId == user.Id).LastOrDefault(); //If user has already made a payment if (payment != null) { //Returns a page with personal information and payment (if such information is found) of a current user return(View(new ServiceRequestModel { RequestedService = new RequestedService { ServiceId = id, UserId = user.Id, FirstName = user.FirstName, LastName = user.LastName, Email = user.Email, Telephone = user.Telephone, Apartment = user.Apartment, City = user.City, Street = user.Street, Province = user.Province, ZIP = user.ZIP }, Payment = payment })); } else { //Returns a page with personal information of a current user return(View(new ServiceRequestModel { RequestedService = new RequestedService { ServiceId = id, UserId = user.Id, FirstName = user.FirstName, LastName = user.LastName, Email = user.Email, Telephone = user.Telephone, Apartment = user.Apartment, City = user.City, Street = user.Street, Province = user.Province, ZIP = user.ZIP } })); } } //Returns a blank page return(View(new ServiceRequestModel { RequestedService = new RequestedService { ServiceId = id } })); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string searchMode = Request.QueryString["SearchMode"].ToString(); GeneralUser user = (Session["UserInfo"] as GeneralUser); int userID = user.Id; string strCon = ""; string strTab = ""; DataTable tempDt; switch (searchMode) { case "Finish": //已处理稿件 tempDt = ArticleManager.GetArticleByAessSendID(userID); //显示本人评论过稿件 break; case "UnFinish": //未处理稿件 strTab = CreateTableCon(user.RoleInfo, userID); strCon = CreateConditionStr(user.RoleInfo, userID); tempDt = ArticleManager.GetArticleForUnfinsh(strTab, strCon); break; default: throw new Exception("不存在的稿件类型"); } //绑定数据 gvArticleList.DataSource = tempDt; gvArticleList.DataBind(); } }
public async Task <ActionResult> UpdateProfile(GeneralUser user) { if (ModelState.IsValid) { try { GeneralUser currentUser = await GetCurrentUserAsync(); currentUser.Apartment = user.Apartment; currentUser.City = user.City; currentUser.FirstName = user.FirstName; currentUser.LastName = user.LastName; currentUser.PhoneNumber = user.PhoneNumber; currentUser.Province = user.Province; currentUser.Street = user.Street; currentUser.Telephone = user.Telephone; currentUser.ZIP = user.ZIP; await userManager.UpdateAsync(currentUser); return(RedirectToAction("Index")); } catch (Exception ex) { Console.WriteLine(ex.Message); return(View(user)); } } return(View(user)); }
public async Task <ActionResult> ProfilePage() { GeneralUser user = await GetCurrentUserAsync(); List <RequestedService> requestedServices = (from service in repository.RequestedServices where service.UserId == user.Id orderby service.Date ascending select service).ToList(); List <ServiceRequestSummary> services = new List <ServiceRequestSummary>(); Payment payment = repository.Payments.Where(p => p.UserId == user.Id).LastOrDefault(); //Loop that is used for combining information from 2 different lists that are //list of requested service and list of payments into //one list of ServiceRequestSummary foreach (var item in requestedServices) { Service ser = (Service)(from service in repository.Services where service.ServiceId == item.ServiceId select service).FirstOrDefault(); ServiceRequestSummary summary = new ServiceRequestSummary { ServiceName = ser.ServiceName, PricePerHour = ser.PricePerHour, Date = item.Date, NumberOfHours = item.NumberOfHours, TotalPrice = item.TotalPrice }; services.Add(summary); } ProfileModel model = new ProfileModel { RequestedServices = services, User = user, UserPayment = payment }; return(View(model)); }
private async Task <GeneralUser> CreateAdminAsync(string email, UserManager <GeneralUser> userManager) { KeePark.Areas.Identity.Pages.Account.RegisterModel.InputModel model = new KeePark.Areas.Identity.Pages.Account.RegisterModel.InputModel { UID = "111111111", FirstName = "Admin", LastName = "Admin", PhoneNumber = "0524897653", CarNumber = "7777777", CarType = "Admin", CreditCard = "12341234123456", Balance = 0, ConfirmPassword = "******", Password = "******", Email = email, Address = "Rishon Lezion" }; var user = new GeneralUser { UserName = model.Email, Email = model.Email, Address = model.Address, Balance = model.Balance, CarNumber = model.CarNumber, CarType = model.CarType, CreditCard = model.CreditCard, FirstName = model.FirstName, LastName = model.LastName, UID = model.UID }; //var s=new KeePark. var result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { return(user); } return(null); }
// GET: ReserveSpots public async Task <IActionResult> Index(string spotsName, DateTime resDate, string carNumber) { var userid = _userManager.GetUserId(HttpContext.User); GeneralUser user = _userManager.FindByIdAsync(userid).Result; var res = (from reservations in _context.ReserveSpot where reservations.UserID == user.UID select reservations).Include(r => r.Spot); var reserves = from r in res select r; // Smart Search if (!String.IsNullOrEmpty(spotsName)) { reserves = reserves.Where(a => a.Spot.SpotName.Contains(spotsName)); } if (resDate != DateTime.MinValue) { reserves = reserves.Where(a => a.ReservationDate.Date.Equals(resDate.Date)); } if (!String.IsNullOrEmpty(carNumber)) { reserves = reserves.Where(a => a.carNumber.Equals(carNumber)); } return(View(await reserves.ToListAsync())); }
public ProjectMatcher(GeneralUser initiator) { if (initiator == null) { throw new NullReferenceException("Initiatior cannot be null"); } _initiator = initiator; }
public ActionResult DeleteConfirmed(int id) { GeneralUser generalUser = db.GeneralUser.Find(id); db.GeneralUser.Remove(generalUser); db.SaveChanges(); return(RedirectToAction("Index")); }
public void ShouldRemoveEmailFromFirstName() { var user = new GeneralUser { FirstName = "*****@*****.**" }; Assert.AreEqual("user", user.FullName); }
public ProviderMatcher(GeneralUser initiator) { if (initiator == null) { throw new NullReferenceException("Student cannot be null"); } _initiator = initiator; }
public void ShouldRemoveAllAfterFirstEmailFromLastName() { var user = new GeneralUser { LastName = "[email protected] [email protected]" }; Assert.AreEqual("user", user.FullName); }
public void ShouldRemoveEmailFromBothFirstAndLastName() { var user = new GeneralUser { FirstName = "*****@*****.**", LastName = "*****@*****.**" }; Assert.AreEqual("user1 user2", user.FullName); }
public void GeneralUserThrowsError() { var client = new TargetProcessClient { ApiSiteInfo = new ApiSiteInfo(TargetProcessRoutes.Route.GeneralUsers) }; var generalUser = new GeneralUser { }; }
public void UserLogin(GeneralUser _GeneralUser) { UserResource objUser = new UserResource(); object[] param ={ _GeneralUser }; objUser.CheckLogin(param); }