public async Task <ConfirmationResultDto> ConfirmUserCredit(UserInformationDto userInformationDto) { if (userInformationDto.IdentityNumber == null || !userInformationDto.IdentityNumber.ValidateIdentityNumber()) { throw new Exception("Identity Number is not true format"); } var creditApplicationEntity = userInformationDto.Adapt <CreditApplication>(); var httpClient = _httpClientFactory.CreateClient("CreditScore.API"); var response = await httpClient.GetAsync(string.Format(CreditScoreApiUrls.GET_SCORE, creditApplicationEntity.IdentityNumber)); if (response.IsSuccessStatusCode) { var responseBody = await response.Content.ReadAsStringAsync(); int.TryParse(responseBody, out var score); var limit = _creditLimitFactory.CalculateCreditLimit(score, userInformationDto.Income); creditApplicationEntity.Score = score; creditApplicationEntity.ConfirmedLimit = limit; creditApplicationEntity.InsertDate = DateTime.Now; // save to db await _creditApplicationRepository.AddAsync(creditApplicationEntity); // send sms //send e-mail if (limit > 0) { var body = string.Format(_appSettings.MailSettings.BodyConfirmed, userInformationDto.FirstName, limit + " TL"); body.SendEmail(_appSettings.MailSettings.From, _appSettings.MailSettings.To, _appSettings.MailSettings.Password); } else { _appSettings.MailSettings.BodyDenied.SendEmail(_appSettings.MailSettings.From, _appSettings.MailSettings.To, _appSettings.MailSettings.Password); } // return response dto return(new ConfirmationResultDto { Confirmed = limit > 0, Limit = limit + "TL" }); } else { throw new Exception("Score Service Error"); } }
public ActionResult <UserInformationDto> AddUserInformation(UserInformationDto userInformationDto) { var userInformation = this.userInformationService.AddUserInformation(userInformationDto); if (userInformation == null) { return(BadRequest(new { message = "Please input the correct verification code." })); } return(CreatedAtRoute(nameof(AddUserInformation), new { Id = userInformationDto.Id }, userInformation)); }
public IActionResult GetLoggedUser(string email) { var user = _userService.GetByMail(email); UserInformationDto userInformation = new UserInformationDto { UserId = user.Id, FirstName = user.FirstName, LastName = user.LastName, Email = user.Email }; if (user != null) { return(Ok(userInformation)); } return(BadRequest("Wrong email")); }
public UserInformationDto MapLoginQuery(SqlDataReader sqlDataReader) { UserInformationDto userInformationDto = MapToUserInformationDto(sqlDataReader); sqlDataReader.NextResult(); while (sqlDataReader.Read()) { userInformationDto.AccessModules.Add(RoleModuleMappers.Instance.MapToRoleModuleDto(sqlDataReader)); } return(userInformationDto); }
public IActionResult UpdateUserInfo([FromBody] UserInformationDto userInformationDto) { var identity = HttpContext.User.Identity as ClaimsIdentity; string email = identity.FindFirst(ClaimTypes.Email).Value; User user = _userService.GetByEmail(email); if (user == null) { return(BadRequest(new ErrorResultDto { Name = ErrorNames.DefaultError, Type = ErrorTypes.Danger, Value = SecurityMessages.SystemError })); } if (userInformationDto.Name != null) { user.Name = userInformationDto.Name; } if (userInformationDto.City != null) { user.City = userInformationDto.City; } if (userInformationDto.Gender != null) { user.Gender = userInformationDto.Gender; } if (userInformationDto.BirthDay != null) { user.BirthDay = userInformationDto.BirthDay; } IResult updateResult = _userService.Update(user); if (!updateResult.Success) { return(BadRequest(new ErrorResultDto { Name = ErrorNames.DefaultError, Type = ErrorTypes.Danger, Value = SecurityMessages.SystemError })); } return(Ok(updateResult.Message)); }
private void UserSignIn(UserInformationDto userInformationDto, OAuthGrantResourceOwnerCredentialsContext context) { List <Claim> claims = GetClaims(userInformationDto); ClaimsIdentity claimsIdentity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie); AuthenticationProperties authenticationProperties = new AuthenticationProperties(new Dictionary <string, string> { { "as:client_id", context.ClientId == null ? string.Empty : context.ClientId }, { "userName", context.UserName } }); authenticationProperties.IsPersistent = true; var ticket = new AuthenticationTicket(claimsIdentity, authenticationProperties); context.Validated(ticket); }
public async Task <ActionResult> GetUserDetails(Guid?id) { //获取当前登陆的id,cookie的id需要解密 string userCookieId = ""; string message; if (Request.Cookies["userId"] != null) { if (!JwtHelper.GetJwtDecode(Request.Cookies["userId"].Value, out userCookieId, out message)) { return(Json(new { result = message, status = "fail", code = 401 }, JsonRequestBehavior.AllowGet));//返回错误信息 } } string userId = Session["userId"] == null ? userCookieId : Session["userId"].ToString(); if (id == null && userId != null && userId.Trim() != "") { return(RedirectToAction(nameof(GetUserDetails), new { id = userId })); } IUserManager userManager = new UserManager(); if (id == null) //未登录不可为空 { return(Json(new { code = 401 }, JsonRequestBehavior.AllowGet)); //仅返回错误代码跳转登陆,不弹提示 } if (!await userManager.ExistsUser(id.Value)) { return(Json(new { result = "未能找到对应ID的用户,请稍后再试", status = "fail" }, JsonRequestBehavior.AllowGet));//返回错误信息 } UserInformationDto userInfo = await userManager.GetUserById(id.Value); IArticleManager articleManager = new ArticleManager(); var latestArticles = await articleManager.GetCurrentUserLatestArticle(5, id.Value, false); //选取5篇最新发布的文章,不含置顶 var topArticles = await articleManager.GetCurrentUserLatestArticle(100, id.Value, true); //选取100篇最新发布的置顶文章(不足100取找到的最大值) var articlesCount = await articleManager.GetArticleDataCount(userInfo.Id); //查找文章总数 var categoriesCount = await articleManager.GetCategoryDataCount(userInfo.Id); //查找分类总数 var isFocused = userId == "" ? false : await userManager.IsFocused(Guid.Parse(userId), id.Value); //id为空也视为没关注 var isCurrentUser = userId == "" ? false : Guid.Parse(userId) == id.Value ? true : false; //是否为当前登陆用户 var tenTags = await articleManager.GetCategoriesByCount(id.Value, 10); //返回10个分类 return(Json(new { status = "ok", userInfo, latestArticles, topArticles, articlesCount, categoriesCount, isFocused, isCurrentUser, tenTags }, JsonRequestBehavior.AllowGet)); }
public MainForm(UserInformationDto userInformation, IServiceRepository serviceRepository, IItemRepository itemRepository, IVehicleRepository vehicleRepository, ITransactionRepository transactionRepository, IEmployeeRepository employeeRepository, IAttendanceRepository attendanceRepository) { InitializeComponent(); UserInformation = userInformation; ServiceRepository = serviceRepository; VehicleRepository = vehicleRepository; TransactionRepository = transactionRepository; ItemRepository = itemRepository; EmployeeRepository = employeeRepository; AttendanceRepository = attendanceRepository; }
public ActionResult GetSetting() { UserInformationDto model = Mapper.Map <UserInformationDto>(AppUser); model.Who = "我"; ViewBag.Title = "个人设置"; ViewBag.Visitor = model; ViewBag.UserProfile = new UserProfileDto { UserName = AppUser.UserName, NickName = AppUser.NickName, Sex = AppUser.sex, ProfileProvince = MyService.GetCurrentProvinceFormProfile(AppUser.Profiles[OldHouseUserProfile.PROFILENBAME]), ProfileCity = MyService.GetCurrentCityFormProfile(AppUser.Profiles[OldHouseUserProfile.PROFILENBAME]) }; return(View()); }
public void AddShouldBeSuccessful() { // 1. Arrange var email = "*****@*****.**"; var vCode = this.verificationCodeHelper.getVerificationCode(email); UserInformationDto userInfo = new UserInformationDto() { FullName = "Tom", PhoneNumber = "02106817023", Email = email, VerificationCode = vCode }; // 2. Act var result = this.userInformationService.AddUserInformation(userInfo); //3. Assert Assert.NotNull(result); }
public async Task <ActionResult> UserDetails(Guid?id) { //获取当前登陆的id,cookie的id需要解密 string userCookieId = ""; string message; if (Request.Cookies["userId"] != null) { if (!JwtHelper.GetJwtDecode(Request.Cookies["userId"].Value, out userCookieId, out message)) { ErrorController.message = message; return(RedirectToAction("IllegalOperationError", "Error"));//返回错误页面 } } string userId = Session["userId"] == null ? userCookieId : Session["userId"].ToString(); if (id == null && userId != null && userId.Trim() != "") { return(RedirectToAction(nameof(UserDetails), new { id = userId })); } IUserManager userManager = new UserManager(); if (id == null || !await userManager.ExistsUser(id.Value)) { ErrorController.message = "未能找到对应ID的用户,请稍后再试"; return(RedirectToAction("IllegalOperationError", "Error"));//返回错误页面 } UserInformationDto user = await userManager.GetUserById(id.Value); IArticleManager articleManager = new ArticleManager(); ViewBag.LatestArticles = await articleManager.GetCurrentUserLatestArticle(5, id.Value, false); //选取5篇最新发布的文章,不含置顶 ViewBag.TopArticles = await articleManager.GetCurrentUserLatestArticle(100, id.Value, true); //选取100篇最新发布的置顶文章(不足100取找到的最大值) ViewBag.ArticlesCount = await articleManager.GetArticleDataCount(user.Id); //查找文章总数 ViewBag.CategoriesCount = await articleManager.GetCategoryDataCount(user.Id); //查找分类总数 ViewBag.IsFocused = userId == "" ? false : await userManager.IsFocused(Guid.Parse(userId), id.Value); //id为空也视为没关注 ViewBag.IsCurrentUser = userId == "" ? false : Guid.Parse(userId) == id.Value ? true : false; //是否为当前登陆用户 ViewBag.TenTags = await articleManager.GetCategoriesByCount(id.Value, 10); //返回10个分类 return(View(user)); }
private void InitializeUserInformation(UserInformationDto userInformationDto) { lock ( _userPermissionsSync ) { lock ( _currentUserContextSync ) { _userPermissions.Clear(); foreach (var grantedPermission in userInformationDto.GrantedPermissions) { var permission = new Permission { Name = grantedPermission }; _userPermissions.Add(permission); } var agency = new AgencyContext( userInformationDto.AgencyKey, userInformationDto.AgencyDisplayName); var location = new LocationContext( userInformationDto.LocationKey, userInformationDto.LocationDisplayName); var staff = new StaffContext( userInformationDto.StaffKey, userInformationDto.StaffFirstName, userInformationDto.StaffMiddleName, userInformationDto.StaffLastName, userInformationDto.DirectEmailAddress); var account = new AccountContext( userInformationDto.AccountKey, userInformationDto.AccountIdentifier); var currentUserContext = new CurrentUserContext( agency, location, staff, account); ChangeContext(currentUserContext); _permissionsInitialized = true; _userPermissionsWeakDelegatesManager.Raise(); } } }
public UserInformationDto MapToUserInformationDto(SqlDataReader sqlDataReader) { UserInformationDto userInformationDto = new UserInformationDto(); userInformationDto.Id = sqlDataReader["Id"].ToInteger(); userInformationDto.FirstName = sqlDataReader["FirstName"].ToString(); userInformationDto.LastName = sqlDataReader["LastName"].ToString(); userInformationDto.UserName = sqlDataReader["UserName"].ToString(); userInformationDto.EmailAddress = sqlDataReader["EmailAddress"].ToString(); userInformationDto.IsFirstTimeLoggedInd = sqlDataReader["IsFirstTimeLoggedInd"].ToBoolean(); userInformationDto.OrganisationId = sqlDataReader["OrganisationId"].ToNullableInteger(); userInformationDto.OrganisationName = sqlDataReader["OrganisationName"].ToString(); userInformationDto.CompanyId = sqlDataReader["CompanyId"].ToNullableInteger(); userInformationDto.CompanyName = sqlDataReader["CompanyName"].ToString(); userInformationDto.CreateDate = sqlDataReader["CreateDate"].ToDateTime().ToString("dd/MM/yyyy"); return(userInformationDto); }
public IActionResult UpdateUser(long id, [FromBody] UserInformationDto userInformationDto) { Logger.LogInformation("Begin update attempt for user id [{0}]", id); //Validate token's claim to the specified user id if (_tokenIssuerService.ValidateToken(User, id)) { //Ensure request body could be deserialized into the desired type if (userInformationDto == null) { //Handle 400 Bad Request Logger.LogInformation("Update attempt for user id [{0}] failed, bad request", id); return(BadRequest()); } //Ensure user entity exists var userEntity = _userRepo.GetUser(id); if (userEntity == null) { //Handle 404 Not Found Logger.LogInformation("Update attempt for user id [{0}] failed, user not found", id); return(NotFound()); } //Map dto values to entity Mapper.Map(userInformationDto, userEntity); //Ensure entity is persisted successfully if (!_userRepo.Save()) { Logger.LogError("Update attempt for user id [{0}] failed, server error", id); return(StatusCode(500, "An error occurred while updating the User")); } //Success! Issue a new JWT and return no content Logger.LogInformation("Update attempt for user id [{0}] successful, user updated", id); AddJwtToResponseHeader(_tokenIssuerService.RenewToken(User)); return(NoContent()); } //Handle authorization failure Logger.LogInformation("Update attempt for user id [{0}] failed, not authorized", id); return(Unauthorized()); }
public async void GetShouldBeSuccessful() { // 1. Arrange var email = "*****@*****.**"; var vCode = this.verificationCodeHelper.getVerificationCode(email); UserInformationDto userInfo = new UserInformationDto() { FullName = "Tom", PhoneNumber = "02106817023", Email = email, VerificationCode = vCode }; // 2. Act var result = this.userInformationService.AddUserInformation(userInfo); var obj = await this.userInformationService.GetUserInformationAsync(result.Id); //3. Assert Assert.NotNull(obj); Assert.Equal(userInfo.FullName, obj.FullName); Assert.Equal(userInfo.PhoneNumber, obj.PhoneNumber); Assert.Equal(userInfo.Email, obj.Email); }
public ActionResult ModifyProfile(UserProfileDto model) { if (ModelState.IsValid) { AppUser.UserName = model.UserName; AppUser.NickName = model.NickName; AppUser.sex = model.Sex; MyService.MyUserManager.UserRepository.SaveOne(AppUser); MyService.AddOrModifyCurrentProvinceForProfile(AppUser.Profiles[OldHouseUserProfile.PROFILENBAME], model.ProfileProvince); MyService.AddOrModifyCurrentCityForProfile(AppUser.Profiles[OldHouseUserProfile.PROFILENBAME], model.ProfileCity); ViewBag.Information = "资料修改成功!"; } UserInformationDto user = Mapper.Map <UserInformationDto>(AppUser); user.Who = "我"; ViewBag.Title = "个人设置"; ViewBag.Visitor = user; ViewBag.UserProfile = model; return(View("Setting")); }
public async Task <ActionResult> PostForgetPassword(string email) { //邮箱为空,邮箱不正确 if (email == null || email.Trim() == "") { return(Json(new { status = "fail", result = "提交的数据不完整!" }, JsonRequestBehavior.AllowGet)); } Regex RegEmail = new Regex("^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info)$");//w 英文字母或数字的字符串,和 [a-zA-Z0-9] 语法一样 Match m = RegEmail.Match(email); if (!m.Success) { return(Json(new { status = "fail", result = "账号必须是邮箱格式的哦!" }, JsonRequestBehavior.AllowGet)); } IUserManager userManager = new UserManager(); UserInformationDto user = await userManager.GetUserByEmail(email); string token; //查找的Email是否存在,在就获取id制作token,否则返回不存在 if (user == null) { return(Json(new { status = "fail", result = "该邮箱不存在,请重试!" }, JsonRequestBehavior.AllowGet)); } token = JwtHelper.SetJwtEncode((user.Id).ToString(), 600);//jwt有效期十分钟 string modelError = await userManager.ForgetPassword(token, user.Id, user.Email); if (modelError != null)//失败 { //在执行发送邮件里记录错误信息 return(Json(new { status = "fail", result = modelError }, JsonRequestBehavior.AllowGet)); } string url = ConfigurationManager.AppSettings["ApiUrl"].ToString() + "/ResetPassword?Token=" + token; if (!MailHelper.SendEmailDefault(user.Email, url)) { return(Json(new { status = "fail", result = "系统邮箱配置错误,邮件发送失败!" }, JsonRequestBehavior.AllowGet)); } ; return(Json(new { status = "ok", result = "发送邮件成功!" }, JsonRequestBehavior.AllowGet)); }
public bool UpdateUserPreferences(UserInformationDto userInformation) { try { InsertOrUpdateUser(userInformation); var user = _unitOfWork.UserRepository.GetSingle(p => p.Email == userInformation.email); if (userInformation.facebookJSON?.likes != null) { SimplerNewsSQLDb db = new SimplerNewsSQLDb(); db.ResetUserPreferences(user.Id); foreach (var like in userInformation.facebookJSON.likes) { var facebookLikeCategory = _unitOfWork.FacebookCategoryRepository.GetSingle(p => p.CategoryName == like.category); if (facebookLikeCategory != null) { var pref = _unitOfWork.UserPreferencesRepository.GetSingle( p => p.YoutubeCategoryId == facebookLikeCategory.VideoCategoryId && p.UserId == user.Id); if (pref != null) { double additionalScore = (1.0 / (DateTime.Now.Year - DateTime.Parse(like.liked_date).Year + 1)); // ReSharper disable once PossibleLossOfFraction decimal addition = Convert.ToDecimal(additionalScore); pref.Score += addition; _unitOfWork.UserPreferencesRepository.Update(pref); _unitOfWork.Save(); } } } } return(true); } catch (Exception e) { throw e; } }
public UserInformation AddUserInformation(UserInformationDto userInformationDto) { UserInformation userInfo = null; if (userInformationDto != null && verificationCodeHelper.CheckVerificationCode(userInformationDto.VerificationCode, userInformationDto.Email)) //verify userInformation { userInfo = new UserInformation() { FullName = userInformationDto.FullName, PhoneNumber = userInformationDto.PhoneNumber, Email = userInformationDto.Email }; this.myDbContext.Add(userInfo); //save this.myDbContext.SaveChanges(); } return(userInfo); }
public ActionResult MyCheckins(string id = "", int page = 1, int pagesize = 6) { if (id.Equals("")) { id = AppUser.Id.ToString(); } var user = MyService.MyUserManager.FindByIdAsync(new Guid(id)).Result; UserInformationDto model = Mapper.Map <UserInformationDto>(user); if (AppUser != null && model.Id.Equals(AppUser.Id)) { model.Who = "我"; } ViewBag.Visitor = model; ViewBag.Title = user.NickName + "的签到"; var lastpage = (int)Math.Ceiling(MyService.FindChenkInCountByUser(user.Id) / (double)pagesize); ViewBag.PageControl = new PageControl(page, lastpage, pagesize); return(View()); }
public async Task <bool> Register(string email, string password) { using (IUserService userSvc = new UserService()) { UserInformationDto user = await GetUserByEmail(email); if (user == null)//如果没有相同邮箱则通过 { await userSvc.CreatAsync(new User() { Email = email, Password = password }); return(true); } else//有相同邮箱则不可 { return(false); } } }
public async Task <List <UserInvitationsDto> > GetInvitations(int profileId) { var invitations = await _invitationService.Queryable() .Where(x => x.RecipientProfileId == profileId) .OrderBy(x => x.SenderProfileId) .ThenBy(x => x.TeamGuid) .ToListAsync(); var sender = new UserInformationDto(); var teamInvitation = new TeamInvitationInformationDto(); var result = new List <UserInvitationsDto>(); foreach (var invitation in invitations) { if (sender.ProfileId != invitation.SenderProfileId) { sender = await _userInformation.GetUserProfileInformationAsync(invitation.SenderProfileId); } if (teamInvitation.TeamGuid != invitation.TeamGuid.ToString()) { teamInvitation = await _teamsManager.GetTeamInviteInformation(invitation.TeamGuid); } result.Add(new UserInvitationsDto { InvitationId = invitation.Id, TeamId = teamInvitation.TeamId, TeamName = teamInvitation.TeamName, Created = invitation.Created, Read = invitation.Read, SenderId = invitation.SenderProfileId, SenderFullName = sender.Name + " " + sender.Surname, SenderProfilePicture = sender.ProfilePicture }); } return(result.OrderByDescending(x => x.Created).ToList()); }
public async Task <ActionResult> ChangeImage(HttpPostedFileBase file) { if (file == null || file.ContentLength == 0) { return(Json(new { status = "fail", result = "图片不可为空,请重试!" }, JsonRequestBehavior.AllowGet)); } IUserManager userManager = new UserManager(); //获取当前登陆的id,cookie的id需要解密 string userCookieId = ""; string message; if (Request.Cookies["userId"] != null) { if (!JwtHelper.GetJwtDecode(Request.Cookies["userId"].Value, out userCookieId, out message)) { return(Json(new { status = "fail", result = message }, JsonRequestBehavior.AllowGet)); } } string userId = Session["userId"] == null ? userCookieId : Session["userId"].ToString();//优先获取session的id if (userId == null || userId.Trim() == "") { return(Json(new { status = "fail", result = "获取用户信息失败,请检查登陆状态" }, JsonRequestBehavior.AllowGet)); } UserInformationDto user = await userManager.GetUserById(Guid.Parse(userId)); if (user.ImagePath != null && user.ImagePath != "default.png")//存在图片路径则删除就图片 { string savepath = Server.MapPath("../Image"); string oldFileName = Path.Combine(savepath, user.ImagePath); System.IO.File.Delete(oldFileName); } string newFileName = ProcessUploadedFile(file); if (!await userManager.ChangeUserImage(Guid.Parse(userId), newFileName)) { return(Json(new { status = "fail", result = "修改失败" }, JsonRequestBehavior.AllowGet)); } return(Json(new { status = "ok", path = newFileName }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Register(string email, string password, string confirmPassword) { //不可为空,账号必须是邮箱格式,邮箱不可重复,密码验证正确 if (email == null || password == null || confirmPassword == null || email.Trim() == "" || password.Trim() == "" || confirmPassword.Trim() == "") { return(Json(new { status = "fail", result = "提交的数据不完整,请重试!" }, JsonRequestBehavior.AllowGet)); } if (password != confirmPassword) { return(Json(new { status = "fail", result = "两次输入的密码不一致!" }, JsonRequestBehavior.AllowGet)); } Regex RegEmail = new Regex("^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info)$");//w 英文字母或数字的字符串,和 [a-zA-Z0-9] 语法一样 Match m = RegEmail.Match(email); if (!m.Success) { return(Json(new { status = "fail", result = "账号必须是邮箱格式的哦!" }, JsonRequestBehavior.AllowGet)); } IUserManager userManager = new UserManager(); UserInformationDto user = await userManager.GetUserByEmail(email); if (user != null)//已经有人使用了该邮箱 { return(Json(new { status = "fail", result = "该邮箱已被使用!" }, JsonRequestBehavior.AllowGet)); } var passWord = Md5Helper.Md5(confirmPassword); if (!await userManager.Register(email, passWord)) { return(Json(new { status = "fail", result = "注册失败!" }, JsonRequestBehavior.AllowGet)); } //注册成功后自动登陆 var registerUser = await userManager.GetUserByEmail(email); Session["loginName"] = registerUser.Email; //将邮箱地址存进session Session["userId"] = registerUser.Id; //将用户id存进session return(Json(new { status = "ok", result = "注册成功!" }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetHomePage(string id = "") { OldHouseUser user = null; if (id.Equals("")) { user = AppUser; } else { user = MyService.MyUserManager.FindByIdAsync(new Guid(id)).Result; } UserInformationDto model = Mapper.Map <UserInformationDto>(user); int count = MyService.GetProfile(user.Profiles[OldHouseUserProfile.PROFILENBAME]).FollowerCount; if (AppUser != null && model.Id.Equals(AppUser.Id)) { model.Who = "我"; } ViewBag.Title = model.NickName + "的主页"; ViewBag.Visitor = model; return(View(model)); }
private void btnLogin_Click(object sender, EventArgs e) { int?selectedBranchId = null; if (comboBranch.SelectedItem != null) { selectedBranchId = GetBranchIdFromComboBox(); } var credentials = new LoginDto { Email = txtboxEmail.Text, Password = txtboxPassword.Text, RememberMe = false }; var validate = LoginRepository.AuthenticateLogin(credentials); var UserInformation = new UserInformationDto() { FirstName = validate.FirstName, LastName = validate.LastName, BranchId = selectedBranchId.Value }; if (validate.IsAuthenticated) { MessageBox.Show(validate.ResponseMessage); var mainForm = new MainForm(UserInformation, ServiceRepository, ItemRepository, VehicleRepository, TransactionRepository, EmployeeRepository, AttendanceRepository); mainForm.LoginForm = this; mainForm.Show(); this.Hide(); } else { MessageBox.Show(validate.ResponseMessage); } }
public ActionResult MyLiked(string id = "", string type = "houses", int page = 1, int pagesize = 6) { if (id.Equals("")) { id = AppUser.Id.ToString(); } var user = MyService.MyUserManager.FindByIdAsync(new Guid(id)).Result; UserInformationDto model = Mapper.Map <UserInformationDto>(user); if (AppUser != null && model.Id.Equals(AppUser.Id)) { model.Who = "我"; } ViewBag.Visitor = model; ViewBag.LikedHouseCount = MyService.FindLikedHouseCountByUser(user.Id); ViewBag.LikedCheckinCount = MyService.CheckInService.FindLikedBlogPostCountByUser(user.Id); ViewBag.Title = user.NickName + "的点赞"; int lastpage = 0; switch (type) { case "houses": lastpage = (int)Math.Ceiling(ViewBag.LikedHouseCount / (double)pagesize); break; case "checkins": lastpage = (int)Math.Ceiling(ViewBag.LikedCheckinCount / (double)pagesize); break; default: break; } ViewBag.PageControl = new PageControl(page, lastpage, pagesize); return(View("Like")); }
public async Task <OperationResult <UserInformationDto> > GetUserInformation(Guid id) { UserInformationDto yg = new UserInformationDto(); try { var userInfo = await Users.Where(x => x.Id == id) .Select(v => new { Result = v.UserRoles.Role.AccessLevels .Select(i => new UserInformationDto { DispayName = $"{v.Name } {v.Family}", AccessUnserInfos = i.Role.AccessLevels.Select(x => x.Access) }).ToList() }).FirstOrDefaultAsync(); return(OperationResult <UserInformationDto> .BuildSuccessResult(userInfo.Result.FirstOrDefault())); } catch (Exception ex) { return(OperationResult <UserInformationDto> .BuildFailure(ex.Message)); } }
public async Task <IActionResult> ConfirmCredit([FromBody] UserInformationDto userInformationDto) { var result = await _creditConfirmationService.ConfirmUserCredit(userInformationDto); return(Ok(result)); }
public async Task <IActionResult> TrainPersonGroup([FromBody] UserInformationDto userInformation) { await _faceService.TrainPersonGroupAsync(userInformation.RegisterUserPhotoUrl, userInformation.Email); return(Ok()); }