public static void NotifyPasswordChange(User user, string password) { var text = "Уважаемый пользователь!<br/>"; text += "Вы запросили новый пароль для входа на сайт http://elfam.ru <br/>" + Environment.NewLine; text += "Ваш новый пароль: " + password + "<br/><br/>"; text += "Администрация Elfam.ru"; Send("Elfam.ru - Восстановление пароля", text, user.Email, "", null); }
public AddOrderResult AddOrder(Cart cart, User user, OrderShippingInfo orderInfo) { if (cart == null) throw new ArgumentException("cart is null"); if (cart.Items == null) throw new ArgumentException("cart items is null"); if (user == null) throw new ArgumentException("user is null"); if (orderInfo == null) throw new ArgumentException("orderInfo is null"); // construct order var orderLines = new List<OrderLine>(); var orderOutcomes = new List<Outcome>(); foreach (CartItem item in cart.Items) { IList<Income> incomes = FindOldestIncomesForProduct(item.Product, item.Quantity); int quantity = item.Quantity; var outcomes = new List<Outcome>(); foreach (Income income in incomes) { int n = Math.Min(quantity, income.QuantityCurrent); income.QuantityCurrent -= n; _daoTemplate.Save(income); Outcome outcome = new Outcome(item.Product.Price, n, income, user.Discount + cart.CurrentDiscount()); quantity -= n; outcomes.Add(outcome); } orderOutcomes.AddRange(outcomes); orderLines.Add(new OrderLine(item.Product, item.Quantity, outcomes)); } Order order = new Order(orderOutcomes, orderLines); order.Comment = orderInfo.Comment ?? ""; DeliverPrices prices = _daoTemplate.FindAll<DeliverPrices>()[0]; if (orderInfo.PaymentType == PaymentType.OnPost) { order.DeliverPrice = prices.PostWhenReceived(cart.SummDiscount()); } else { order.DeliverPrice = GetPrice(orderInfo.DeliverType); } order.CopyFrom(orderInfo); order.User = user; order.Discount = user.Discount + cart.CurrentDiscount(); _daoTemplate.Save(order); order.Uid = _daoTemplate.FindByID<UniqueId>(order.Id).Uid; _daoTemplate.Save(order); return new AddOrderResult(){Order = order}; }
public void SetUp() { _product = new Product() { Id = 1 }; _incomesForProduct = new List<Income> { new Income() { BuyPrice = 10, Date = new DateTime(2000, 6, 28), Id = 1, Product = _product, QuantityCurrent = 10, QuantityInital = 10 }, new Income() { BuyPrice = 20, Date = new DateTime(2000, 5, 28), Id = 2, Product = _product, QuantityCurrent = 10, QuantityInital = 10 }, new Income() { BuyPrice = 30, Date = new DateTime(2000, 4, 28), Id = 3, Product = _product, QuantityCurrent = 10, QuantityInital = 10 }, new Income() { BuyPrice = 40, Date = new DateTime(2000, 3, 28), Id = 4, Product = _product, QuantityCurrent = 10, QuantityInital = 10 }, new Income() { BuyPrice = 50, Date = new DateTime(2000, 2, 28), Id = 5, Product = _product, QuantityCurrent = 10, QuantityInital = 10 }, }; _emptyIncome = new Income() { BuyPrice = 50, Date = new DateTime(1980, 2, 28), Id = 6, Product = _product, QuantityCurrent = 0, QuantityInital = 0 }; _incomesForProduct.Add(_emptyIncome); _product.Incomes = _incomesForProduct; _cartItems = new List<CartItem> { new CartItem() {Product = _product, Quantity = 33} }; _user = new User() { }; _shippingInfo = new OrderShippingInfo() { }; _daoTemplate = new Mock<IDaoTemplate>(); _daoTemplate.Setup(x => x.FindByID<Product>(1)).Returns(_product); _daoTemplate.Setup(x => x.FindByID<UniqueId>(0)).Returns(new UniqueId() { Uid = 123 }); _orderService = new OrderService(); _orderService.DaoTemplate = _daoTemplate.Object; }
public void AddUsers() { string[] cities = {"Москва", "Калуга", "Тула", "Брянск"}; string[] streets = { "Ленина", "Кирова", "Московская", "Чичерина" }; string[] domens = { "mail.ru", "gmail.com", "yandex.ru" }; string[] nicks = { "vasya", "jane", "oleg" }; string[] surnames = { "Аверин", "Дуров", "Медведев", "Тихонов", "Кузнецов" }; string[] names = { "Андрей", "Денис", "Михаил", "Анатолий", "Кирилл" }; using (ISession session = GetConfiguration().BuildSessionFactory().OpenSession()) { Contact contact = new Contact() { City = "Калуга", Country = "РФ", House = "18", Name = "Алексей", Phone = "555-939", Region = "Калужская обл.", Room = "21", Surname = "Покревский", Street = "Чичерина", Zip = "248010" }; DeliverPrices prices = new DeliverPrices() { CourierMoscow = 250, CourierSubMoscow = 300, Post = 170, Self = 0 }; session.Save(prices); User user = new User() { Contact = contact, Email = "*****@*****.**", Role = Role.Admin}; user.PasswordHash = UserService.CalculateHash("1"); session.Save(user); session.Flush(); //return; Random r = new Random(); int n =r.Next(5, 10); for(int i = 0; i < 11; i++) { contact = new Contact() { City = cities[r.Next(cities.Length)], Country = "РФ", House = r.Next(1, 99) + "", Name = names[r.Next(names.Length)], Phone = string.Format("{0}({1}){2}-{3}-{4}", r.Next(1, 9), r.Next(100, 999), r.Next(100, 999), r.Next(10, 99), r.Next(10, 99)), Region = "Калужская обл.", Room = r.Next(1, 99) + "", Surname = surnames[r.Next(surnames.Length)], Street = streets[r.Next(streets.Length)], Zip = "ABCDF" }; User user1 = new User() { Contact = contact, Email = string.Format("{0}{2}@{1}", nicks[r.Next(nicks.Length)], domens[r.Next(domens.Length)], i), Role = Role.User, Discount = r.Next(5) * 100 }; user1.PasswordHash = UserService.CalculateHash("1"); session.Save(user1); session.Flush(); } } }
public virtual bool Equals(User other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.Email, Email); }
public ActionResult Register(UserViewModel viewModel) { ValidateInput(viewModel); if (ModelState.IsValid) { User user = new User(); user.Contact = Contact.From(viewModel.Contact); user.Email = viewModel.Email; user.IsSignedForNews = viewModel.IsSignForNews; user.PasswordHash = UserService.CalculateHash(viewModel.Password); daoTemplate.Save(user); FormsAuthentication.SetAuthCookie(user.Email, true); return Redirect("/"); } return View(viewModel); }
public void UpdateUserDicount(User user, ControllerContext context) { var summ = user.Summ(); if (summ >= 10000) { user.Discount = 10; string message = MailService.RenderViewToString("~/Views/MailTemplates/Discount.aspx", user, context); MailService.Send("Elfam.ru - Уведомление", message, user.Email); } _daoTemplate.Save(user); }