public static string GetInvoice(DefaultContext db, UserProfile userProfile, BankAccount bankAccountForClaAccess, DateTime currentDate, out string invoiceNumber) { invoiceNumber = PropertiesBagCache.GetClaAccessInvoiceNumber(db); var vocabulary = new Dictionary<string, string> { {"InvoiceNumber", invoiceNumber}, {"VS", BankAccountHistory.GetVs(userProfile.LyonessId).ToString(CultureInfo.InvariantCulture)}, {"ICO", userProfile.ICO}, {"DIC", userProfile.DIC}, {"Address", String.Format("{0} {1}\n{2}\n{3} {4}", userProfile.FirstName, userProfile.LastName, userProfile.Address, userProfile.PSC, userProfile.City)}, {"AccountId", bankAccountForClaAccess.AccountId}, {"IBAN", bankAccountForClaAccess.IBAN}, {"SWIFT", bankAccountForClaAccess.SWIFT}, {"Date", currentDate.ToString("dd.MM.yyyy")}, {"Currency", userProfile.ClaAccessCurrency.ToString()}, {"Price", userProfile.ClaAccessYearlyAccess.ToString(CultureInfo.InvariantCulture)} }; string invoice = ProcessVocabulary(Properties.Resources.Invoice, vocabulary); return invoice; }
private static DeleteResult Delete(DefaultContext db, UrlHelper urlHelper, int id, bool checkLeadedUser, out UserProfile userProfile, int userId = 0, bool isAdmin = false) { userProfile = GetDetail(db, id); if (userProfile == null) return DeleteResult.AuthorizationFailed; if (checkLeadedUser) { bool isUserLeader = GetLeadedUserIds(db, userId).Contains(userProfile.UserId); if (!isAdmin && !isUserLeader) { return DeleteResult.AuthorizationFailed; } } string[] roles = Roles.GetRolesForUser(userProfile.UserName); try { UserProfile registrar = GetDetail(db, userProfile.RegistrarId.GetValueOrDefault()); ModifyMeetingAttendees(db, urlHelper, userProfile, registrar); ModifyMeetings(db, urlHelper, userProfile, registrar); var parameter = new SqlParameter(UserIdSqlParameter, userProfile.UserId); db.Database.ExecuteSqlCommand(CascadeRemoveUserProcedureTemplate, parameter); } catch (Exception e) { if (!Roles.GetRolesForUser(userProfile.UserName).Any()) Roles.AddUserToRoles(userProfile.UserName, roles); Logger.SetLog(e); return DeleteResult.DbFailed; } try { var parameter = new SqlParameter(UserIdSqlParameter, userProfile.UserId); db.Database.ExecuteSqlCommand(CascadeRemoveUserProfileProcedureTemplate, parameter); return DeleteResult.Ok; } catch (Exception e) { Logger.SetLog(e); return DeleteResult.DbFailed; } }
public CheckBillingInformation(DefaultContext db, int userId) { _userProfile = UserProfileCache.GetDetail(db, userId); if (_userProfile == null) return; UserId = _userProfile.UserId; FirstName = _userProfile.FirstName; LastName = _userProfile.LastName; Address = _userProfile.Address; City = _userProfile.City; PSC = _userProfile.PSC; DIC = _userProfile.DIC; ICO = _userProfile.ICO; }
public SettingsProfile(UserProfile userProfile) : base(userProfile) { Address = userProfile.Address; PSC = userProfile.PSC; DIC = userProfile.DIC; ICO = userProfile.ICO; ReminderTime = userProfile.ReminderTime; IsEventsPrivate = userProfile.IsEventsPrivate; }
private void SendEmail(UserProfile userProfile, string newPassword, ref ModelStateDictionary modelStateDictionary) { if (userProfile == null) return; string textBody = String.Format(MailResource.AccountController_PasswordRecovery_TextBody, newPassword); if (Mail.SendEmail(userProfile.Email1, MailResource.AccountController_PasswordRecovery_Subject, textBody, true, true)) return; modelStateDictionary.AddModelError(BaseCache.UserNameField, ValidationResource.Account_CannotSendEmailForPasswordRecovery_ErrorMessage); }
private void ValidateActiveUser(UserProfile userProfile, ref ModelStateDictionary modelStateDictionary) { if (userProfile != null && userProfile.Active) return; modelStateDictionary.AddModelError(BaseCache.UserNameField, ValidationResource.Account_LockedAccount_ErrorMessage); }
private void ValidateClaAccess(ref ModelStateDictionary modelStateDictionary, DefaultContext db, UserProfile userProfile) { // Kontrola na platnost přístup s platbou za přístup if (userProfile.IsAdmin || userProfile.ClaAccessExpired >= DateTime.Now) return; decimal amountRemains = userProfile.ClaAccessYearlyAccess - userProfile.ClaAccessAmount; string paymentInformation = BankAccountCache.GetPaymentInfo(db, userProfile.ClaAccessCurrency, userProfile.LyonessId, amountRemains); string errorMessage = String.Format(ValidationResource.Account_AccountAccessIsExpired_ErrorMessage, paymentInformation); modelStateDictionary.AddModelError(String.Empty, errorMessage); }
public UserProfileLockedUnlocked(UserProfile userProfile) { UserName = userProfile.UserName; FirstName = userProfile.FirstName; LastName = userProfile.LastName; }
protected UserProfileEditBase(UserProfile userProfile) { Role = userProfile.Role; UserId = userProfile.UserId; UserName = userProfile.UserName; LyonessId = userProfile.LyonessId; Title = userProfile.Title; LastName = userProfile.LastName; FirstName = userProfile.FirstName; City = userProfile.City; DistrictId = userProfile.DistrictId; PhoneNumberPrefix1Id = userProfile.PhoneNumberPrefix1Id; PhoneNumber1 = userProfile.PhoneNumber1; PhoneNumberPrefix2Id = userProfile.PhoneNumberPrefix2Id; PhoneNumber2 = userProfile.PhoneNumber2; Email1 = userProfile.Email1; Email2 = userProfile.Email2; Skype = userProfile.Skype; SmsEmail = userProfile.SmsEmail; UseMail = userProfile.UseMail; UseSms = userProfile.UseSms; GoogleCredentialsJson = userProfile.GoogleCredentialsJson; GoogleCalendarId = userProfile.GoogleCalendarId; UseGoogleCalendar = userProfile.UseGoogleCalendar; PremiumMembershipGranted = userProfile.PremiumMembershipGranted; MspCoach = userProfile.MspCoach; Ca = userProfile.Ca; Presenting = userProfile.Presenting; Tasks = userProfile.Tasks; Note = userProfile.Note; LCIDDropDownList = userProfile.LCID; AutomaticLogoutInterval = userProfile.AutomaticLogoutInterval; ClaAccessAmountWithCurrency = userProfile.ClaAccessAmountWithCurrency; ClaAccessYearlyAccesWithCurrency = userProfile.ClaAccessYearlyAccesWithCurrency; ClaAccessExpired = userProfile.IsAdmin ? null : userProfile.ClaAccessExpired; }
private void Validate() { if (_userId == BaseController.UserId) { SetStatusMessage(ValidationResource.UserProfile_CannotPromoteYourself_ErrorMessage); return; } _userProfile = UserProfileCache.GetDetail(BaseController.Db, _userId); if (_userProfile != null && _userProfile.Role == RoleType.AuthGuest) return; SetStatusMessage(ValidationResource.UserProfile_CannotPromoteUser_ErrorMessage); }
private bool IsEditable(UserProfile userProfile, int id) { if (userProfile == null || userProfile.IsPoliciesAccepted && !IsAdmin) return false; return IsAccess(id); }
private bool IsAccess(UserProfile userProfile, int id) { if (userProfile == null) return false; return IsAccess(id); }
private static void SetRole(ref UserProfile userProfile) { if (userProfile != null) { userProfile.Role = UserProfile.GetRoleForUser(userProfile.UserName); } }
private static void ModifyMeetings(DefaultContext db, UrlHelper urlHelper, UserProfile userProfile, UserProfile registrar) { var meetings = db.Meetings.Where( m => m.OrganizerId == userProfile.UserId || m.MainLeaderId == userProfile.UserId || m.SecondaryOrganizerId == userProfile.UserId || m.SecondaryLeaderId == userProfile.UserId).Include( m => m.MainLeader).ToArray(); DateTime currentDateTime = DateTime.Now; var mailMessages = new List<MailMessage>(); bool modified = false; foreach (Meeting meeting in meetings) { string meetingUrl = Url.GetActionAbsoluteUrl(urlHelper, MeetingCache.GetMeetingAction(meeting), "Meeting", new { id = meeting.MeetingId }); if (meeting.MainLeaderId == userProfile.UserId) { if (registrar == null) throw new Exception(RegistrarIsNullErrorMessage); meeting.MainLeaderId = registrar.UserId; meeting.MainLeader = registrar; modified = true; if (meeting.Finished > currentDateTime && registrar.UseMail) { string textBody = String.Format(MailResource.UserProfileController_MainLeaderChanged_TextBody, meeting.Title, meetingUrl); var mailMessage = new MailMessage { Address = registrar.Email1, Subject = MailResource.UserProfileController_MainLeaderChanged_Subject, TextBody = textBody }; mailMessages.Add(mailMessage); } } if (meeting.OrganizerId == userProfile.UserId) { meeting.OrganizerId = meeting.MainLeaderId; modified = true; if (meeting.Finished > currentDateTime && meeting.MainLeader.UseMail) { string textBody = String.Format(MailResource.UserProfileController_OrganizerChanged_TextBody, meeting.Title, meetingUrl); var mailMessage = new MailMessage { Address = meeting.MainLeader.Email1, Subject = MailResource.UserProfileController_OrganizerChanged_Subject, TextBody = textBody }; mailMessages.Add(mailMessage); } } if (meeting.SecondaryOrganizerId == userProfile.UserId) { meeting.SecondaryOrganizerId = null; meeting.SecondaryOrganizer = null; modified = true; } if (meeting.SecondaryLeaderId == userProfile.UserId) { if (registrar == null) throw new Exception(RegistrarIsNullErrorMessage); meeting.SecondaryLeaderId = registrar.UserId; meeting.SecondaryLeader = registrar; modified = true; if (meeting.Finished > currentDateTime && registrar.UseMail) { string textBody = String.Format(MailResource.UserProfileController_SecondaryLeaderChanged_TextBody, meeting.Title, meetingUrl); var mailMessage = new MailMessage { Address = registrar.Email1, Subject = MailResource.UserProfileController_SecondaryLeaderChanged_Subject, TextBody = textBody }; mailMessages.Add(mailMessage); } } } if (modified) { db.SaveChanges(); } foreach (MailMessage mailMessage in mailMessages) { Mail.SendEmail(mailMessage.Address, mailMessage.Subject, mailMessage.TextBody, true, true); } }
private static void ModifyMeetingAttendees(DefaultContext db, UrlHelper urlHelper, UserProfile userProfile, UserProfile registrar) { DateTime currentDateTime = DateTime.Now; bool modified = false; MeetingAttendee[] meetingAttendeesByRegistrar = db.MeetingAttendees.Where(ma => ma.RegistrarId == userProfile.UserId).ToArray(); foreach (MeetingAttendee meetingAttendee in meetingAttendeesByRegistrar) { if (registrar == null) throw new Exception(RegistrarIsNullErrorMessage); meetingAttendee.RegistrarId = registrar.UserId; meetingAttendee.Registrar = registrar; modified = true; } var mailMessages = new List<MailMessage>(); MeetingAttendee[] meetingAttendeesByUserAttendee = db.MeetingAttendees.Where(ma => ma.UserAttendeeId == userProfile.UserId && ma.Meeting.Finished > currentDateTime && userProfile.UseMail).Include(ma => ma.Meeting).ToArray(); // ReSharper disable LoopCanBeConvertedToQuery foreach (MeetingAttendee meetingAttendee in meetingAttendeesByUserAttendee) // ReSharper restore LoopCanBeConvertedToQuery { string meetingUrl = Url.GetActionAbsoluteUrl(urlHelper, MeetingCache.GetMeetingAction(meetingAttendee.Meeting), "Meeting", new { id = meetingAttendee.Meeting.MeetingId }); string textBody = String.Format(MailResource.UserProfileController_UserAttendeeWasRemoved_TextBody, meetingAttendee.Meeting.Title, meetingUrl); var mailMessage = new MailMessage { Address = userProfile.Email1, Subject = MailResource.UserProfileController_UserAttendeeWasRemoved_Subject, TextBody = textBody }; mailMessages.Add(mailMessage); } int userId = userProfile.UserId; IQueryable<int> peopleContactIds = db.PeopleContacts.Where(pc => pc.RegistrarId == userId).Select(pc => pc.PeopleContactId); MeetingAttendee[] meetingAttendeesByAttendee = db.MeetingAttendees.Where(ma => ma.AttendeeId != null && peopleContactIds.Contains(ma.AttendeeId.Value) && ma.Meeting.Finished > currentDateTime && userProfile.UseMail).Include(ma => ma.Meeting).ToArray(); // ReSharper disable LoopCanBeConvertedToQuery foreach (MeetingAttendee meetingAttendee in meetingAttendeesByAttendee) // ReSharper restore LoopCanBeConvertedToQuery { string meetingUrl = Url.GetActionAbsoluteUrl(urlHelper, MeetingCache.GetMeetingAction(meetingAttendee.Meeting), "Meeting", new { id = meetingAttendee.Meeting.MeetingId }); string textBody = String.Format(MailResource.UserProfileController_AttendeeWasRemoved_TextBody, meetingAttendee.Attendee.FullName, meetingAttendee.Meeting.Title, meetingUrl); var mailMessage = new MailMessage { Address = userProfile.Email1, Subject = MailResource.UserProfileController_AttendeeWasRemoved_Subject, TextBody = textBody }; mailMessages.Add(mailMessage); } if (modified) { db.SaveChanges(); } foreach (MailMessage mailMessage in mailMessages) { Mail.SendEmail(mailMessage.Address, mailMessage.Subject, mailMessage.TextBody, true, true); } }
public UserProfileDelete(UserProfile userProfile) { UserName = userProfile.UserName; FirstName = userProfile.FirstName; LastName = userProfile.LastName; LyonessId = userProfile.LyonessId; }
public static UserProfileDelete GetModelView(UserProfile userProfile) { if (userProfile == null) return null; var userProfileDelete = new UserProfileDelete(userProfile); return userProfileDelete; }
protected void ValidateChangeClaAccessCurrency(UserProfile userProfile, Currency[] currencies, ref ModelStateDictionary modelStateDictionary) { ClaAccessAmountWithCurrency = userProfile.ClaAccessAmountWithCurrency; ClaAccessYearlyAccesWithCurrency = userProfile.ClaAccessYearlyAccesWithCurrency; ClaAccessExpired = userProfile.IsAdmin ? null : userProfile.ClaAccessExpired; OriginalClaAccessAmount = userProfile.ClaAccessAmount; OriginalClaAccessCurrency = userProfile.ClaAccessCurrency; if (ClaAccessChangedCurrency == null || ClaAccessChangedCurrency == userProfile.ClaAccessCurrency) { ClaAccessAmount = userProfile.ClaAccessAmount; ClaAccessYearlyAccess = userProfile.ClaAccessYearlyAccess; ClaAccessCurrency = userProfile.ClaAccessCurrency; return; } try { ClaAccessAmount = CurrencyHelper.ConvertTo(userProfile.ClaAccessAmount, userProfile.ClaAccessCurrency, ClaAccessChangedCurrency.Value, currencies); ClaAccessYearlyAccess = userProfile.ClaAccessFixCurrencyChange ? userProfile.GetClaAccessYearlyAccess(ClaAccessChangedCurrency.Value) : (int) Math.Round(CurrencyHelper.ConvertTo(userProfile.ClaAccessYearlyAccess, userProfile.ClaAccessCurrency, ClaAccessChangedCurrency.Value, currencies)); } catch (Exception e) { modelStateDictionary.AddModelError(BaseCache.ClaAccessChangedCurrencyField, e.Message); return; } ClaAccessCurrency = ClaAccessChangedCurrency.Value; }
public static UserProfileLockedUnlocked GetModelView(UserProfile userProfile) { if (userProfile == null) return null; var userProfileLocked = new UserProfileLockedUnlocked(userProfile); return userProfileLocked; }
public UserProfileEdit(UserProfile userProfile) : base(userProfile) { }
private void ProcessLogin(ref ModelStateDictionary modelStateDictionary, UserProfile userProfile) { if (WebSecurity.IsAuthenticated) { WebSecurity.Logout(); } if (modelStateDictionary.Count > 0) return; if (WebSecurity.Login(UserName, Password, RememberMe)) { UserId = userProfile.UserId; return; } if (modelStateDictionary.Count > 0) return; int passwordFailuresSinceLastSuccess = Settings.Default.AllowedPasswordAttempts - WebSecurity.GetPasswordFailuresSinceLastSuccess(UserName); modelStateDictionary.AddModelError(String.Empty, String.Format(ValidationResource.Account_LoginFailed_ErrorMessage, passwordFailuresSinceLastSuccess)); }
private void ValidateChangeRole(UserProfile userProfile, ref ModelStateDictionary modelStateDictionary) { if (userProfile.Role == RoleType.AuthGuest && Role != RoleType.AuthGuest) { modelStateDictionary.AddModelError(BaseCache.RoleField, ValidationResource.Account_CannotChangeRole_ErrorMessage); } if (userProfile.Role != RoleType.AuthGuest && Role == RoleType.AuthGuest) { modelStateDictionary.AddModelError(BaseCache.RoleField, ValidationResource.Account_CannotChangeRoleToAuthGuest_ErrorMessage); } }
private void ResetPassword(UserProfile userProfile, string newPassword, ref ModelStateDictionary modelStateDictionary) { if (userProfile == null) return; string passwordResetToken = WebSecurity.GeneratePasswordResetToken(userProfile.UserName); if (WebSecurity.ResetPassword(passwordResetToken, newPassword)) return; modelStateDictionary.AddModelError(BaseCache.UserNameField, ValidationResource.Account_PasswordRecoveryFailed_ErrorMessage); }
private void AddAdditionalInformation(bool isAdmin, UserProfile userProfile) { if (!isAdmin) { Role = userProfile.Role; } UserName = userProfile.UserName; }
private void SetDefaultData(UserProfile registrar) { DateTime currentDateTime = DateTime.Now; AccessGranted = currentDateTime; RegistrarId = registrar.UserId; ClaAccessExpired = DateTime.MaxValue; ClaAccessYearlyAccessCZK = registrar.ClaAccessYearlyAccessCZK; ClaAccessYearlyAccessEUR = registrar.ClaAccessYearlyAccessEUR; ClaAccessYearlyAccessUSD = registrar.ClaAccessYearlyAccessUSD; ClaAccessTrial = false; ClaAccessFixCurrencyChange = registrar.ClaAccessFixCurrencyChange; LCID = registrar.LCID; }
public UserProfileDetails(UserProfile userProfile) { UserId = userProfile.UserId; UserName = userProfile.UserName; FirstName = userProfile.FirstName; LastName = userProfile.LastName; BillingInformation = SetBillingInformation(userProfile); Role = UserProfile.GetRoleTypeDisplayName(userProfile.Role); IsAdmin = userProfile.IsAdmin; Title = userProfile.Title; City = userProfile.City; District = DistrictDetails.GetModelView(userProfile.District); PhoneNumberPrefix1 = PhoneNumberPrefixDetails.GetModelView(userProfile.PhoneNumberPrefix1); PhoneNumber1 = userProfile.PhoneNumber1; PhoneNumberPrefix2 = PhoneNumberPrefixDetails.GetModelView(userProfile.PhoneNumberPrefix2); PhoneNumber2 = userProfile.PhoneNumber2; Email1 = userProfile.Email1; Email2 = userProfile.Email2; GoogleCredentialsJson = userProfile.GoogleCredentialsJson; GoogleCalendarId = userProfile.GoogleCalendarId; PremiumMembershipGranted = userProfile.PremiumMembershipGranted; AccessGranted = userProfile.AccessGranted; RegistredPeopleQuota = userProfile.RegistredPeopleQuota; RegistredPeopleQuotaLastMonth = userProfile.RegistredPeopleQuotaLastMonth; PremiumPartnersQuota = userProfile.PremiumPartnersQuota; PremiumPartnersQuotaLastMonth = userProfile.PremiumPartnersQuotaLastMonth; BuyersQuota = userProfile.BuyersQuota; ContactedPeopleCount = userProfile.ContactedPeopleCount; ContactedPeopleCountLastMonth = userProfile.ContactedPeopleCountLastMonth; Ca = userProfile.Ca; Presenting = userProfile.Presenting; MspCoach = userProfile.MspCoach; LastAccessed = userProfile.LastAccessed; Active = userProfile.Active; LyonessId = userProfile.LyonessId; Note = userProfile.Note; Tasks = userProfile.Tasks; Skype = userProfile.Skype; ClaAccessExpired = userProfile.ClaAccessExpired; ClaAccessAmountWithCurrency = userProfile.ClaAccessAmountWithCurrency; ClaAccessYearlyAccesWithCurrency = userProfile.ClaAccessYearlyAccesWithCurrency; IsPoliciesAccepted = userProfile.IsPoliciesAccepted; }
private void AddAdditionalInformation(UserProfile userProfile, bool isAdmin) { Role = userProfile.Role; UserName = userProfile.UserName; if (!isAdmin) { PremiumMembershipGranted = userProfile.PremiumMembershipGranted; Ca = userProfile.Ca; Presenting = userProfile.Presenting; MspCoach = userProfile.MspCoach; } }
public static UserProfileDetails GetModelView(UserProfile userProfile) { if (userProfile == null) return null; var userProfileDetails = new UserProfileDetails(userProfile); return userProfileDetails; }
private void ValidateActiveAccount(ref ModelStateDictionary modelStateDictionary, UserProfile userProfile) { // Kontrola na zamknutí účtu kvůli neaktivnímu účtu. if (userProfile.Active) return; modelStateDictionary.AddModelError(String.Empty, ValidationResource.Account_AccountIsLocked_ErrorMessage); }
private string SetBillingInformation(UserProfile userProfile) { var billingInformation = new StringBuilder(); billingInformation.AppendLine(String.Format("{0} {1}", userProfile.FirstName, userProfile.LastName)); billingInformation.AppendLine(userProfile.Address); billingInformation.AppendLine(String.Format("{0} {1}\n", userProfile.PSC, userProfile.City)); billingInformation.AppendLine(String.Format("{0}: {1}", FieldResource.Global_ICO_Name, userProfile.ICO)); billingInformation.AppendLine(String.Format("{0}: {1}", FieldResource.Global_DIC_Name, userProfile.DIC)); return billingInformation.ToString(); }