public static void ClonePayersDataFromPreviousTransfer(this PaymentForm paymentForm, User buyer) { paymentForm.PersonalData = new PaymentFormPersonalData {Email = AuthenticationHelper.CurrentUser.Email}; var previousPayment = AuthenticationHelper.CurrentUser.Transfers.LastOrDefault(t => t.Payment != null); if (previousPayment != null) { paymentForm.PersonalData.FirstName = previousPayment.Payment.FirstName; paymentForm.PersonalData.LastName = previousPayment.Payment.LastName; } }
public static string EmailHeader(User user) { var header = ""; if (user.IsExpert) { header = string.Format(Resources.Email.HeadExpert, user.Expert.PublicName); } if (!user.IsExpert) { header = Resources.Email.Head; } return header; }
public static User CreateUser(PaymentForm form, UrlHelper url) { var repository = HttpContext.Current.GetDbRepository(); var user = new User { Email = form.PersonalData.Email }; if (form.SignUp) { user.Password = form.PasswordForm.Password; } else { user.IsNoSignUpUser = true; } repository.User.Add(user); repository.User.AddEmailConfigurationDefaultValue(user); if (form.SignUp) { Flash.Info(Resources.Account.AccountCreatedFromPayment); Email.Send<ActivationEmail>(user); } else { Flash.Info(Resources.Account.AnonymousAccountCreated); Email.Send<ActivationEmail>(user); } AuthenticationHelper.Authenticate(user.Email); return user; }
//IService void IService.AttachOwner(User user) { Expert = user.Expert; }
public static MvcHtmlString ProfileAvatar(this HtmlHelper htmlHelper, User user) { if (user.IsExpert && user.Expert.HasPicture) return htmlHelper.ProfilePicture80x80(user.Expert.Id); if (user.IsConsultant) return htmlHelper.ConsulantPicture80x80(); return htmlHelper.DefaultPicture80x80(); }
void IService.AttachOwner(User owner) { Author = owner; foreach(var post in Posts) if (post.Author == null) post.Author = owner; }
private void CreatePartner(User user) { if (!user.IsPartner) Repository.Partner.Create(user); }
private void GenerateBDDTestingData() { //generating users var userSalt = CryptoHelper.CreateSalt(); var user = new User { Email = "*****@*****.**", IsActivated = true, Password = "******", PasswordSalt = userSalt, BankAccountNumber = "654510157739999994584019961664" }; Repository.User.Add(user); Repository.User.AddEmailConfigurationDefaultValue(user); var moderator = new Moderator { PublicName = "Szalony Moderator", User = new User { Email = "*****@*****.**", IsActivated = true, Password = "******", PasswordSalt = userSalt, BankAccountNumber = "116910157739999994584019961664" } }; Repository.User.Add(moderator.User); Repository.Moderator.Add(moderator); Repository.User.AddEmailConfigurationDefaultValue(moderator.User); var expert1 = new Expert { FirstName = "test-name", LastName = "test-surname", PublicName = "test-expert", PhoneNumber = "671707525", VerificationStatus = ExpertVerificationStatus.Verified, User = new User { Email = "*****@*****.**", IsActivated = true, Password = "******", PasswordSalt = userSalt, BankAccountNumber = "204510157739991764584019961664" } }; foreach (var category in Repository.Category.All()) { expert1.Categories.Add(category); expert1.CategoryAttributes.Add(new ExpertCategoryAttributeValues { Category = category, ExpertReason = category.Name + " dfuq am i doing here"} ); } expert1.Microprofiles.Add(new ExpertMicroprofile { Description = "test-desc", Position = "test-position" }); Repository.User.Add(expert1.User); Repository.Expert.Add(expert1); Repository.User.AddEmailConfigurationDefaultValue(expert1.User); Repository.Expert.AssignProvisionToExpert(expert1, ProvisionExpert.Novice); Repository.Partner.Create(expert1.User); var expert2 = new Expert { FirstName = "test-name2", LastName = "test-surname2", PublicName = "test-expert2", PhoneNumber = "271707325", VerificationStatus = ExpertVerificationStatus.Verified, User = new User { Email = "*****@*****.**", IsActivated = true, Password = "******", PasswordSalt = userSalt, BankAccountNumber = "404510157739991344584019961664" } }; foreach (var category in Repository.Category.All()) { expert2.Categories.Add(category); expert2.CategoryAttributes.Add(new ExpertCategoryAttributeValues { Category = category, ExpertReason = category.Name + " dfuq am i doing here 2" } ); } expert2.Microprofiles.Add(new ExpertMicroprofile { Description = "test-desc2", Position = "test-position2" }); Repository.User.Add(expert2.User); Repository.Expert.Add(expert2); Repository.User.AddEmailConfigurationDefaultValue(expert2.User); Repository.Expert.AssignProvisionToExpert(expert2, ProvisionExpert.Novice); Repository.Partner.Create(expert2.User); //generating threads //zadane, opłacone pytanie ([email protected]) bez eksperta var thread1 = new Thread { Priority = ThreadPriority.Medium, Verbosity = ThreadVerbosity.Low, State = ThreadState.Unoccupied, SanitizationStatus = ThreadSanitizationStatus.NotSanitized, Value = 5.00m, IsPaid = true, Author = user, Posts = new List<Post>{new Post { Content = "Pytanie testowe bez eksperta", CreationDate = DateTime.Now.AddDays(-2), LastModificationDate = DateTime.Now.AddDays(-2), Type = PostType.Question, Author = user } }, Category = Repository.Category.Find(c => c.Name == "Nauka") }; thread1.PriceProposals.Add(new PriceProposal { Comment = "Proponuje wyższą cenę", CreationDate = DateTime.Now.AddDays(-1), LastModificationDate = DateTime.Now.AddDays(-1), Expert = expert2, SurchargeValue = 10, VerificationStatus = PriceProposalVerificationStatus.Verified }); Repository.Thread.Add(thread1); thread1.CreationDate = DateTime.Now.AddDays(-2); Repository.Thread.Update(thread1); //zadane, opłacone pytanie z autorem ([email protected]) z ekspertem ([email protected]) var thread2 = new Thread { Priority = ThreadPriority.Medium, Verbosity = ThreadVerbosity.Low, State = ThreadState.Occupied, SanitizationStatus = ThreadSanitizationStatus.NotSanitized, Value = 5.00m, IsPaid = true, Author = user, Expert = expert1, Posts = new List<Post> { new Post { Content = "Pytanie testowe z ekspertem", Type = PostType.Question, Author = user }, new Post { Content = "Odpowiedź testowa", Type = PostType.Answer, Author = expert1.User } }, Category = Repository.Category.Find(c => c.Name == "Nauka") }; Repository.Thread.Add(thread2); // zadane, nieopłacone pytanie var thread3 = new Thread { Priority = ThreadPriority.Medium, Verbosity = ThreadVerbosity.High, State = ThreadState.Unoccupied, SanitizationStatus = ThreadSanitizationStatus.NotSanitized, Value = 20.00m, IsPaid = false, Author = user, Posts = new List<Post> { new Post { Content = "Nieopłacone pytanie testowe", Type = PostType.Question, Author = user } }, Category = Repository.Category.Find(c => c.Name == "Nauka") }; Repository.Thread.Add(thread3); var thread4 = new Thread { Priority = ThreadPriority.Low, Verbosity = ThreadVerbosity.Medium, State = ThreadState.Closed, SanitizationStatus = ThreadSanitizationStatus.NotSanitized, Value = 10.00m, IsPaid = true, Author = user, Posts = new List<Post> { new Post { Content = "Zamknięte pytanie testowe", Type = PostType.Question, Author = user }, new Post { Content = "Odpowiedź testowa", Type = PostType.Answer, Author = expert1.User } }, Category = Repository.Category.Find(c => c.Name == "Nauka") }; Repository.Thread.Add(thread4); //zamkniete i oczyszczone pytanie var thread5 = new Thread { Priority = ThreadPriority.Low, Verbosity = ThreadVerbosity.Medium, State = ThreadState.Closed, SanitizationStatus = ThreadSanitizationStatus.Sanitized, Value = 10.00m, IsPaid = true, Author = user, Expert = expert1, Posts = new List<Post> { new Post { Content = "Zamknięte pytanie testowe sanitized", Type = PostType.Question, Author = user }, new Post { Content = "Odpowiedź testowa sanitized", Type = PostType.Answer, Author = expert1.User } }, Category = Repository.Category.Find(c => c.Name == "Nauka") }; Repository.Thread.Add(thread5); /* generating SEO keywords */ var seoKeyword1 = new SEOKeyword { Category = Repository.Category.Find(c => c.Name == "Nauka"), Phrase = "ekspert", Type = SEOKeywordType.Expert, Status = SEOKeywordStatus.Processed, Source = SEOKeywordSource.Automatic }; Repository.SEOKeyword.Add(seoKeyword1); var seoKeyword2 = new SEOKeyword { Category = Repository.Category.Find(c => c.Name == "Nauka"), Phrase = "fraza", Type = SEOKeywordType.Phrase, Status = SEOKeywordStatus.Processed, Source = SEOKeywordSource.Automatic }; Repository.SEOKeyword.Add(seoKeyword2); var seoKeyword3 = new SEOKeyword { Category = Repository.Category.Find(c => c.Name == "Nauka"), Phrase = "pytanie", Type = SEOKeywordType.Question, Status = SEOKeywordStatus.Processed, Source = SEOKeywordSource.Automatic }; Repository.SEOKeyword.Add(seoKeyword3); }
public static void AddTransfer(this IService service, Transfer transfer, User buyer) { service.Transfers.Add(transfer); buyer.Transfers.Add(transfer); }