public async Task <IActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl = null) { if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await _signInManager.GetExternalLoginInfoAsync(); if (info == null) { return(View("ExternalLoginFailure")); } var user = new MemberUser { UserName = model.Email, Email = model.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(6, "User created an account using {Name} provider.", info.LoginProvider); return(RedirectToLocal(returnUrl)); } } AddErrors(result); } ViewData["ReturnUrl"] = returnUrl; return(View(model)); }
private async Task <IActionResult> SignIn(MemberUser user, string token, string tokenType, string returnUrl) { if (user == null) { return(RedirectToAction("Index", "Home")); } var isValid = await _userManager.VerifyUserTokenAsync(user, tokenType, "passwordless-auth", token); if (!isValid) { return(RedirectToPage("/Account/LoginConfirmation", new { user.Email, returnUrl, showError = true })); } await _userManager.UpdateSecurityStampAsync(user); if (await _userManager.IsEmailConfirmedAsync(user)) { await _signInManager.SignInAsync(user, true, IdentityConstants.ApplicationScheme); return(Redirect(Url.IsLocalUrl(returnUrl) ? returnUrl : "/")); } var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); await _userManager.ConfirmEmailAsync(user, code); await _signInManager.SignInAsync(user, true, IdentityConstants.ApplicationScheme); return(RedirectToPage("/Account/Register", new { returnUrl })); }
public static void ConsecutiveUsersOfMember(BizPortalSessionContext context, int funtionId, List <int> listId, ref string message, ref int warningCount, ref int errorCount) { User userConsecutive = null; string lang = context.CurrentLanguage.Code; string functionName = ""; foreach (int userId in listId) // 1 2 3 n select { using (ITransaction tx = context.PersistenceSession.BeginTransaction()) { try { MemberUser member = context.PersistenceSession.Get <MemberUser>(userId); userConsecutive = member; functionName = Messages.MemberUser.ConseccutiveUser.Format(lang, userConsecutive.LoginName); userConsecutive.ConsecutiveFailedLoginCount = 0; userConsecutive.LastLoginTimestamp = DateTime.Now; userConsecutive.Persist(context); tx.Commit(); message += String.Format("- {0} {1} <br/>", functionName, Messages.Genaral.Success.Format(lang)); context.Log(funtionId, 0, 0, Messages.MemberUser.EnableUser.Format(lang, ""), functionName); } catch (Exception ex) { tx.Rollback(); errorCount++; context.Log((int)funtionId, 0, 0, Messages.MemberUser.ConseccutiveUser.Format(lang, ""), functionName + ex.Message); } } } }
public static void ReinstateUsersOfMember(Context context, int funtionId, List <int> listId, ref string message, ref int warningCount, ref int errorCount) { User userReinState = null; string lang = context.CurrentLanguage.Code; string functionName = ""; foreach (int userId in listId) // 1 2 3 n select { using (ITransaction tx = context.PersistenceSession.BeginTransaction()) { try { MemberUser member = context.PersistenceSession.Get <MemberUser>(userId); userReinState = member; functionName = Messages.MemberUser.ReinStateUser.Format(lang, userReinState.LoginName); ((SelfAuthenticatedUser)userReinState).IsReinstated = false; userReinState.IsNotFinalized = false; userReinState.Persist(context); tx.Commit(); message += String.Format("- {0} {1} <br/>", functionName, Messages.Genaral.Success.Format(lang)); context.Log(funtionId, 0, 0, Messages.MemberUser.EnableUser.Format(lang, ""), functionName); } catch (Exception ex) { tx.Rollback(); errorCount++; context.Log((int)funtionId, 0, 0, Messages.MemberUser.ReinStateUser.Format(lang, ""), functionName + ex.Message); } } } }
public static (FeeStatus FeeStatus, Fee Fee) GetTrainingFee(this MemberUser user) { if (user.HasPayedTrainingFeeThisSemester()) { return(FeeStatus.Paid, null); } if (user.ExemptFromTrainingFee) { return(FeeStatus.Unpayable, null); } if (user.HasPayedMembershipThisYear()) { return( FeeStatus.Unpaid, new Fee("Treningsavgift", TrainingFee, includesTraining: true) ); } return( FeeStatus.Unpaid, new Fee("Medlemskap og treningsavgift", MembershipFee + TrainingFee, includesMembership: true, includesTraining: true) ); }
public static MemberUser RegisterViewModelToUser(this RegisterViewModel registerViewModel) { int categorySelection = 0; categorySelection += Convert.ToInt32(registerViewModel.ActionChecked) * (int)GameCategoryOptions.Action + Convert.ToInt32(registerViewModel.AdventureChecked) * (int)GameCategoryOptions.Adventure + Convert.ToInt32(registerViewModel.RolePlayingChecked) * (int)GameCategoryOptions.RolePlaying + Convert.ToInt32(registerViewModel.SimulationChecked) * (int)GameCategoryOptions.Simulation + Convert.ToInt32(registerViewModel.StrategyChecked) * (int)GameCategoryOptions.Strategy + Convert.ToInt32(registerViewModel.PuzzleChecked) * (int)GameCategoryOptions.Puzzle; int platformSelection = 0; platformSelection += Convert.ToInt32(registerViewModel.PCChecked) * (int)FavoritePlatforms.PC + Convert.ToInt32(registerViewModel.PlayStationChecked) * (int)FavoritePlatforms.PlayStation + Convert.ToInt32(registerViewModel.XboxChecked) * (int)FavoritePlatforms.Xbox + Convert.ToInt32(registerViewModel.NintendoChecked) * (int)FavoritePlatforms.Nintendo + Convert.ToInt32(registerViewModel.MobileChecked) * (int)FavoritePlatforms.Mobile; MemberUser user = new MemberUser() { FirstName = registerViewModel.FirstName, LastName = registerViewModel.LastName, Sex = registerViewModel.Sex, BirthDate = registerViewModel.BirthDate, SendPromotionalEmails = registerViewModel.SendPromotionalEmails, CategoryOptions = categorySelection, PlatformOptions = platformSelection, //MailingAddress = registerViewModel.MailingAddress, //ShippingAddress = registerViewModel.ShippingAddress }; return(user); }
/// <summary> /// Get User from MemberUser.User of status , Active, Expire, Disable /// </summary> /// <param name="memberUser"></param> /// <param name="context"></param> /// <param name="color"></param> /// <returns></returns> public static string GetUserStatus(MemberUser memberUser, BizPortalSessionContext context, ref Color color) { string status = ""; switch (memberUser.Status) { case UserStatus.Active: status = Messages.MemberUser.Active.Format(context.CurrentLanguage.Code); // Active color = Color.Green; break; case UserStatus.Expired: case UserStatus.Expired | UserStatus.Inactive: case UserStatus.Expired | UserStatus.TooManyFailedLogin: status = Messages.MemberUser.Expire.Format(context.CurrentLanguage.Code); // Canceled color = Color.Red; break; case UserStatus.Disable: case UserStatus.Disable | UserStatus.Inactive: // Suspended case UserStatus.Disable | UserStatus.TooManyFailedLogin: // Suspended case UserStatus.TooManyFailedLogin: case UserStatus.TooManyFailedLogin | UserStatus.Inactive: // Loock case UserStatus.Inactive: // Suspended status = Messages.MemberUser.Lock.Format(context.CurrentLanguage.Code); color = Color.Black; break; default: //status = memberUser.User.Status.ToString(); //color = Color.Blue; break; } return(status); }
public static Data.Event ToEntity(this EventInputModel model, MemberUser user) => new Data.Event { Title = model.Title, Description = model.Description, Type = model.Type, CreatedAt = TimeProvider.UtcNow, CreatedByUser = user, SignupOptions = new EventSignupOptions { RequiresMembershipFee = model.RequiresMembershipFee, RequiresTrainingFee = model.RequiresTrainingFee, RequiresClassesFee = model.RequiresClassesFee, PriceForMembers = model.PriceForMembers, PriceForNonMembers = model.PriceForNonMembers, SignupOpensAt = GetUtc(model.EnableSignupOpensAt, model.SignupOpensAtDate, model.SignupOpensAtTime), SignupClosesAt = GetUtc(model.EnableSignupClosesAt, model.SignupClosesAtDate, model.SignupClosesAtTime), SignupHelp = model.SignupHelp, RoleSignup = model.RoleSignup, RoleSignupHelp = model.RoleSignupHelp, AllowPartnerSignup = model.AllowPartnerSignup, AllowPartnerSignupHelp = model.AllowPartnerSignupHelp, AutoAcceptedSignups = model.AutoAcceptedSignups } };
public ActionResult CreateAccount(CreateAccountViewModel NewAccount) { if (NewAccount.IsAccountNameExist()) { return(View(NewAccount)); } if (!NewAccount.IsInputPwIdentity()) { return(View(NewAccount)); } MemberUser MemAccount = new MemberUser(); MemAccount.UserLastName = NewAccount.UserLastName; MemAccount.UserFirstName = NewAccount.UserFirstName; MemAccount.UserEmail = NewAccount.UserEmail; MemAccount.AccountName = NewAccount.AccountName; NewAccount.EncryptPw(); MemAccount.AccountPassword = NewAccount.EncryptPassword; db.MemberUsers.Add(MemAccount); db.SaveChanges(); return(RedirectToAction("Index", "User")); }
public MemberUserView(Context context, MemberUser memberUser, MemberUserGroup memberUserGroup) { if (memberUser == null) { return; } ID = memberUser.ID; LoginName = memberUser.LoginName ?? ""; Name = memberUser.Name != null?memberUser.Name.ToString(context.CurrentLanguage.Code) : ""; Email = memberUser.EMailAddress ?? ""; MobileNumber = memberUser.MobilePhoneNumber ?? ""; CreatedBy = memberUser.CreateAction != null ? memberUser.CreateAction.ByUser.LoginName : ""; CreatedTimeStamp = memberUser.CreateAction != null ? memberUser.ApproveAction.Timestamp.ToString( Service.DateTimeFormat) : ""; ApprovedBy = memberUser.ApproveAction != null ? memberUser.ApproveAction.ByUser.LoginName : ""; ApprovedTimeStamp = memberUser.ApproveAction != null ? memberUser.ApproveAction.Timestamp.ToString( Service.DateTimeFormat) : ""; Status = UserService.GetUserStatus(memberUser, context.CurrentLanguage.Code); User = memberUser; MemberUserGroup = memberUserGroup; }
// // GET: /Manage/ChangeAccountDetails public async Task <ActionResult> ChangeAccountDetails() { var userId = User.Identity.GetUserId(); var memberUser = new MemberUser(); using (CVGSAppEntities db = new CVGSAppEntities()) { memberUser = db.MemberUsers.FirstOrDefault(m => m.Id == userId); } var categoryPrefs = (GameCategoryOptions)memberUser.CategoryOptions; var platformPrefs = (FavoritePlatforms)memberUser.PlatformOptions; var model = new UserViewModel { DisplayName = User.Identity.Name, Email = await UserManager.GetEmailAsync(userId), FirstName = memberUser.FirstName, LastName = memberUser.LastName, BirthDate = memberUser.BirthDate, Sex = memberUser.Sex == null ? 2 : (int)memberUser.Sex, ActionChecked = categoryPrefs.HasFlag(GameCategoryOptions.Action), AdventureChecked = categoryPrefs.HasFlag(GameCategoryOptions.Adventure), RolePlayingChecked = categoryPrefs.HasFlag(GameCategoryOptions.RolePlaying), SimulationChecked = categoryPrefs.HasFlag(GameCategoryOptions.Simulation), StrategyChecked = categoryPrefs.HasFlag(GameCategoryOptions.Strategy), PuzzleChecked = categoryPrefs.HasFlag(GameCategoryOptions.Puzzle), PCChecked = platformPrefs.HasFlag(FavoritePlatforms.PC), PlayStationChecked = platformPrefs.HasFlag(FavoritePlatforms.PlayStation), XboxChecked = platformPrefs.HasFlag(FavoritePlatforms.Xbox), NintendoChecked = platformPrefs.HasFlag(FavoritePlatforms.Nintendo), MobileChecked = platformPrefs.HasFlag(FavoritePlatforms.Mobile), SendPromotionalEmails = memberUser.SendPromotionalEmails == null ? false : (bool)memberUser.SendPromotionalEmails }; return(View(model)); }
public async Task <ActionResult> Register(RegisterViewModel model) { string passwordRegex = @"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{6,}$"; Regex re = new Regex(passwordRegex); // Password validation if (!re.IsMatch(model.Password)) { ModelState.AddModelError("Password", "The password must contain at least one uppercase, one lowercase, one digint and one special character."); } // Display name validation if (UserManager.FindByName(model.DisplayName) != null) { ModelState.AddModelError("DisplayName", "An account with this display name already exists."); } // Email validation if (UserManager.FindByEmail(model.Email) != null) { ModelState.AddModelError("Email", "An account with this email address already exists."); } // Birth date validation if (model.BirthDate > DateTime.Now.AddYears(-18)) { ModelState.AddModelError("BirthDate", "You must be at least 18 years of age to register."); } if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.DisplayName, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { MemberUser newUser = model.RegisterViewModelToUser(); newUser.Id = user.Id; _db.MemberUsers.Add(newUser); _db.SaveChanges(); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Manage")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public MemberUserView(Context context, MemberUser memberUser) { ID = memberUser.ID; LoginName = "<a href=\"javascript:void(0)\" title=\"คลิกเพื่อดูรายละเอียด\" onclick=\"ShowDetail('<%# Container.KeyValue %>','')" + ">" + memberUser.LoginName ?? "" + "</a>"; Name = memberUser.Name != null?memberUser.Name.ToString(context.CurrentLanguage.Code) : ""; Email = memberUser.EMailAddress ?? ""; MobileNumber = memberUser.MobilePhoneNumber ?? ""; CreatedBy = memberUser.CreateAction != null ? memberUser.CreateAction.ByUser.LoginName : ""; CreatedTimeStamp = memberUser.CreateAction != null ? memberUser.ApproveAction.Timestamp.ToString( Service.DateTimeFormat) : ""; ApprovedBy = memberUser.ApproveAction != null ? memberUser.ApproveAction.ByUser.LoginName : ""; ApprovedTimeStamp = memberUser.ApproveAction != null ? memberUser.ApproveAction.Timestamp.ToString( Service.DateTimeFormat) : ""; Status = UserService.GetUserStatus(memberUser, "en-US"); EffectiveMemberGroups = GroupOfUser(memberUser.EffectiveMemberGroups); EffectiveFrom = memberUser.EffectivePeriod == null ? "" : memberUser.EffectivePeriod.EffectiveDate.ToString(ServiceLayer.Service.DateTimeFormat); EffectiveTo = memberUser.EffectivePeriod == null ? "" : memberUser.EffectivePeriod.ExpiryDate.ToString(ServiceLayer.Service.DateTimeFormat); UpdatedBy = memberUser.UpdateAction.ByUser.LoginName; UpdatedTimestamp = memberUser.UpdateAction.Timestamp.ToString(Service.DateTimeFormat); LastLoginTimestamp = memberUser.LastLoginTimestamp.ToString(Service.DateTimeFormat); LastLogoutTimestamp = memberUser.LastLogoutTS.ToString(Service.DateTimeFormat); LastFailedLoginTimestamp = memberUser.LastFailedLoginTimestamp.ToString(Service.DateTimeFormat); ConsecutiveFailedLoginCount = Convert.ToString(memberUser.ConsecutiveFailedLoginCount); TransactionStatus = memberUser.IsNotFinalized || memberUser.IsNotFinalized ? "รออนุมัติ" : ""; }
public static AddressesViewModel MemberUserToAddressesViewModel(this MemberUser memberUser) { var addresses = new AddressesViewModel { MailingAddressApartment = memberUser.MailingAddressApartment ?? string.Empty, MailingAddressStreetNumber = memberUser.MailingAddressStreetNumber ?? string.Empty, MailingAddressStreetName = memberUser.MailingAddressStreetName ?? string.Empty, MailingAddressCity = memberUser.MailingAddressCity ?? string.Empty, MailingAddressProvince = memberUser.MailingAddressProvince ?? string.Empty, MailingAddressPostalCode = memberUser.MailingAddressPostalCode ?? string.Empty, ShippingAddressApartment = memberUser.ShippingAddressApartment ?? string.Empty, ShippingAddressStreetNumber = memberUser.ShippingAddressStreetNumber ?? string.Empty, ShippingAddressStreetName = memberUser.ShippingAddressStreetName ?? string.Empty, ShippingAddressCity = memberUser.ShippingAddressCity ?? string.Empty, ShippingAddressProvince = memberUser.ShippingAddressProvince ?? string.Empty, ShippingAddressPostalCode = memberUser.ShippingAddressPostalCode ?? string.Empty, ShippingAddressSame = memberUser.MailingAddressApartment == memberUser.ShippingAddressApartment && memberUser.MailingAddressStreetNumber == memberUser.ShippingAddressStreetNumber && memberUser.MailingAddressStreetName == memberUser.ShippingAddressStreetName && memberUser.MailingAddressCity == memberUser.ShippingAddressCity && memberUser.MailingAddressProvince == memberUser.ShippingAddressProvince ? true : false }; return(addresses); }
private async Task SendEmail(EventSaveModel input, EventStatusModel model, MemberUser currentUser, bool statusChanged, EventSignup eventSignup) { try { await _emailService.SendCustomEmail( eventSignup.User.Email, input.Subject, input.Message, model); if (statusChanged) { eventSignup.AuditLog.Add($"Moved to {input.Status} and sent email\n\n---\n\n> {input.Subject}\n\n{input.Message}", currentUser); } else { eventSignup.AuditLog.Add($"Sent email\n\n---\n\n> {input.Subject}\n\n{input.Message}", currentUser); } } catch (Exception e) { // Mail sending might fail, but that should't stop us eventSignup.AuditLog.Add($"Tried to send email, but failed with message {e.Message}", currentUser); _logger.LogError(e, "Failed to send email"); } }
public void TestNoPayments() { var user = new MemberUser(); user.HasPayedMembershipThisYear().ShouldBeFalse(); user.HasPayedTrainingFeeThisSemester().ShouldBeFalse(); user.HasPayedClassesFeeThisSemester().ShouldBeFalse(); }
public ActionResult DeleteConfirmed(Guid id) { MemberUser memberuser = db.MemberUsers.Find(id); db.MemberUsers.Remove(memberuser); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// ExpireUsers /// </summary> /// <param name="context">SessionContext is persist</param> /// <param name="funtionId">function BankAdminFunctionID</param> /// <param name="listId">users target</param> /// <param name="message">string ref : message</param> /// <param name="warningCount">int ref : count of warning</param> /// <param name="errorCount">int ref : count of error</param> public static void ExpireUsersNonApproval(BizPortalSessionContext context, int funtionId, List <int> listId, ref string message, ref int warningCount, ref int errorCount) { User userTarget = null; string lang = context.CurrentLanguage.Code; string functionName = ""; BizPortalFunction function = null; DateTime EffectiveDate = DateTime.Now; foreach (int userId in listId) // 1 2 3 n select { using (ITransaction tx = context.PersistenceSession.BeginTransaction()) { try { userTarget = context.PersistenceSession.Get <MemberUser>(userId); functionName = Messages.MemberUser.ExpireUser.Format(lang, userTarget.LoginName); MemberUser mem = context.PersistenceSession.Get <MemberUser>(userId); MaintenanceWorkflow workflow = GetFunctionWorkflowFormFunctionID(funtionId, context.User); if (workflow.MemberFunction != null) { function = workflow.MemberFunction.Function; } else { warningCount++; message += string.Format("- {0} <br/>", Messages.Genaral.IsNotMemberFunction.Format(lang)); } TerminateMemberUserTransaction transactionMember = new TerminateMemberUserTransaction(context, workflow, EffectiveDate, context.Member, mem); mem.Terminate(EffectiveDate); mem.Terminate(EffectiveDate); if (mem.IsNotFinalized) // if user reinstate but logon admin expire user this { mem.IsNotFinalized = false; } mem.Persist(context); transactionMember.Transit(context, workflow, functionName, TransitionEventCode.SubmitEvent); transactionMember.Persist(context); tx.Commit(); message += String.Format("- {0} {1} <br/>", functionName, Messages.Genaral.Success.Format(lang)); context.Log(funtionId, 0, 0, Messages.MemberUser.ExpireUser.Format(lang, ""), functionName); } catch (Exception ex) { tx.Rollback(); errorCount++; message += Messages.Genaral.TransactionException.Format(lang, ex.Message) + "<br/>"; context.Log((int)funtionId, 0, 0, Messages.MemberUser.ExpireUser.Format(lang, ""), functionName + Messages.Genaral.TransactionException.Format(lang, ex.Message)); } } } }
public ActionResult UserItem(MemberUser user) { MemberUser saveUser = db.MemberUsers.Find(user.Id); saveUser.IsApproved = user.IsApproved; saveUser.IsLockedOut = user.IsLockedOut; db.SaveChanges(); return(View("_UserItem", saveUser)); }
// // GET: /MemberUser/Delete/5 public ActionResult Delete(Guid?id = null) { MemberUser memberuser = db.MemberUsers.Find(id); if (memberuser == null) { return(HttpNotFound()); } return(View(memberuser)); }
public ActionResult Edit(MemberUser memberuser) { if (ModelState.IsValid) { db.Entry(memberuser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RoleId = new SelectList(db.MemberRoles, "Id", "RoleName", memberuser.RoleId); return(View(memberuser)); }
// // GET: /MemberUser/Edit/5 public ActionResult Edit(Guid?id = null) { MemberUser memberuser = db.MemberUsers.Find(id); if (memberuser == null) { return(HttpNotFound()); } ViewBag.RoleId = new SelectList(db.MemberRoles, "Id", "RoleName", memberuser.RoleId); return(View(memberuser)); }
public void SetTo(MemberUser member) { Check.NotNull(member, nameof(member)); member.NickName = NickName; member.Gender = Gender == 1 ? AbpProjectName.Gender.Male : AbpProjectName.Gender.Female; member.HeadLogo = AvatarUrl; member.City = City; member.Province = Province; member.Country = Country; member.UnionId = UnionId; }
public static void Reinstate(Context context, int functionId, int pageID, IList <int> listId, string action, ref string message, ref int warningCount) { User userReinState = null; string lang = context.CurrentLanguage.Code; string functionName = ""; foreach (int userId in listId) // 1 2 3 n select { using (ITransaction tx = context.PersistenceSession.BeginTransaction()) { try { MemberUser memberUser = context.PersistenceSession.Get <MemberUser>(userId); userReinState = memberUser; functionName = Messages.MemberUser.ReinStateUser.Format(lang, userReinState.LoginName); //if (userReinState.IsNotFinalized == true) //{ // warningCount++; // message += string.Format("- {0} <br/>", Messages.Genaral.TransactionApproved.Format(lang)); //} if (userReinState is SelfAuthenticatedUser) { ((SelfAuthenticatedUser)userReinState).IsReinstated = true; } else if (userReinState is ActiveDirectoryUser) { ((ActiveDirectoryUser)userReinState).IsReinstated = true; } //Add Update By and update timeStamp //memberUser.UpdateAction.ByUser = context.User; //memberUser.UpdateAction.Timestamp = DateTime.Now; memberUser.UpdateAction = new UserAction(context.User);//by kittikun 2014-05-21 userReinState.Persist(context); tx.Commit(); message += String.Format("- {0} {1} {2}", functionName, Messages.Genaral.Success.Format(lang), newLineHTML); context.Log(functionId, pageID, 0, action, functionName); } catch (Exception ex) { tx.Rollback(); warningCount++; context.Log((int)functionId, pageID, 0, action, functionName + Messages.Genaral.TransactionException.Format(lang, ex.Message)); } } } }
public static (FeeStatus FeeStatus, Fee Fee) GetMembershipFee(this MemberUser user) { if (user.HasPayedMembershipThisYear()) { return(FeeStatus.Paid, null); } return( FeeStatus.Unpaid, new Fee("Medlemskap", MembershipFee, includesMembership: true) ); }
public ActionResult Create(MemberUser memberuser) { if (ModelState.IsValid) { memberuser.Id = Guid.NewGuid(); db.MemberUsers.Add(memberuser); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RoleId = new SelectList(db.MemberRoles, "Id", "RoleName", memberuser.RoleId); return(View(memberuser)); }
public void TestClassesFee_ExcemptClasses_NoPayments() { var user = new MemberUser { ExemptFromClassesFee = true }; var(status, fee) = user.GetClassesFee(); status.ShouldBe(FeeStatus.Unpayable); fee.ShouldBeNull(); }
public async Task <string> LoginLink(MemberUser user, string returnUrl) { var token = await _userManager.GenerateUserTokenAsync(user, "LongToken", "passwordless-auth"); return(_urlHelper.ActionLink( "Index", "LoginCallback", new { userId = user.Id, token, returnUrl })); }
/// <summary> /// Memthod UserCanAccess /// </summary> /// <param name="memberUser"></param> /// <param name="functionIds"></param> /// <returns>Access right of each MemberUser</returns> public bool UserCanAccess(MemberUser memberUser, IList <int> functionIds) { foreach (var wf in memberUser.GetEffectiveCreatorMaintenanceWorkflows()) { foreach (var functionId in functionIds) { if (wf.MemberFunction.FunctionID == functionId) { return(true); } } } return(false); }
public void TestPaidLastYear() { var user = new MemberUser { Payments = { Payment(paidAt: TimeProvider.UtcNow.AddYears(-1), membership: true, training: true, classes: true) } }; user.HasPayedMembershipThisYear().ShouldBeFalse(); user.HasPayedTrainingFeeThisSemester().ShouldBeFalse(); user.HasPayedClassesFeeThisSemester().ShouldBeFalse(); }