Пример #1
0
        public ActionResult Deposits(string KeyCode)
        {
            try
            {
                UserProfile profile = new UserProfile(User.Identity.Name);
                var x = entities.PaymentSystems;

                foreach (var i in x)
                {
                    if (i.KeyCode.Equals(KeyCode) && i.IsActive == true && i.UserName == User.Identity.Name)
                    {
                        profile.Money += i.Nominal;
                        i.IsActive = false;
                        profile.Save();
                    }
                    else { return RedirectToAction("Index"); }
                }

                if (ModelState.IsValid)
                {
                    entities.SaveChanges();
                }

                return RedirectToAction("Successful");
            }
            catch (Exception) { return RedirectToAction("Index"); }
        }
Пример #2
0
        public object MailToAdmin(string subject, string body)
        {
            try
            {
                UserProfile profile = new UserProfile(User.Identity.Name);

                message.To.Add(Resources.GlobalString.userSmtp);

                message.Subject = subject;
                message.From = new MailAddress(Resources.GlobalString.userSmtp);
                message.Body = body + "<br /><b>" + User.Identity.Name + "</b><br />" + profile.LastName + "   " + profile.FirstName + "   " + profile.Money + "<br />" + profile.Address + "   " + profile.Phone;
                message.IsBodyHtml = true;

                smtp.Host = Resources.GlobalString.hostSmtp;

                if (!String.IsNullOrEmpty(Resources.GlobalString.userSmtp))
                {
                    smtp.Credentials = new System.Net.NetworkCredential(Resources.GlobalString.userSmtp, Resources.GlobalString.passSmtp);
                }
                smtp.Send(message);

                message.Dispose();

                return RedirectToAction("MailWasSent");
            }
            catch (Exception) { return RedirectToAction("Index"); }
        }
Пример #3
0
        public ActionResult MoreReg(string Phone)
        {
            UserProfile profile = new UserProfile(User.Identity.Name);
            profile.Phone = Phone;
            profile.Save();

            return RedirectToAction("Register", "Account");
        }
Пример #4
0
        public ActionResult Edit(FormCollection collection)
        {
            UserProfile profile = new UserProfile(User.Identity.Name);
            UpdateModel(profile, collection);
            profile.Save();

            return RedirectToAction("Index");
        }
Пример #5
0
        public Order OrderFillingProfile(string UserName, string paymentSystemRu, string paymentSystemEn, int iOrderStatusesNumber,
            string orderStatusRu, string orderStatusEn)
        {
            UserProfile profile = new UserProfile(UserName);
            order.FirstName = profile.FirstName;
            order.LastName = profile.LastName;
            order.Phone = profile.Phone;
            order.Address = profile.Address;
            order.UserName = UserName;
            order.Email = Membership.GetUser(UserName).Email;

            order.Date = DateTime.Now;
            order.PaymentSysRu = paymentSystemRu;
            order.PaymentSysEn = paymentSystemEn;
            order.OrderStatusRu = string.Empty;

            if (iOrderStatusesNumber > 0) {
                order.OrderStatusRu = orderStatusRu;
                order.OrderStatusEn = orderStatusEn;
            }

            return order;
        }
Пример #6
0
        public ActionResult Register(RegisterModel model, string Phone)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    MembershipCreateStatus createStatus;
                    Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                    if (createStatus == MembershipCreateStatus.Success)
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, false);

                        if (!Roles.IsUserInRole(model.UserName, Constants.ROLE_USER))
                            Roles.AddUserToRole(model.UserName, Constants.ROLE_USER);

                        UserProfile profile = new UserProfile(model.UserName);
                        profile.Phone = Phone;
                        profile.Save();

                        return RedirectToAction("Index", "Home");
                    }
                    else
                    {
                        ModelState.AddModelError("", ErrorCodeToString(createStatus));
                    }
                }

                return View(model);
            }
            catch (Exception) { return RedirectToAction("Index", "Home"); }
        }
Пример #7
0
 public ActionResult Index()
 {
     UserProfile profile = new UserProfile(User.Identity.Name);
     return View(profile);
 }
Пример #8
0
 public ActionResult ChangeValueProfile(string LastName, string FirstName, string Phone, string Address)
 {
     UserProfile profile = new UserProfile(User.Identity.Name);
     Dictionary<int, int> cart = Session[Resources.GlobalString.SESSION_CART] as Dictionary<int, int>;
     if (cart != null)
     {
         profile.LastName = LastName;
         profile.FirstName = FirstName;
         profile.Phone = Phone;
         profile.Address = Address;
         profile.Save();
     }
     return RedirectToAction("Index");
 }
Пример #9
0
        public ActionResult Save(string LastName, string FirstName, string Phone, string Address, string Email, string PaymentSys)
        {
            UserProfile profile = new UserProfile(User.Identity.Name);
            Dictionary<int, int> cart = Session[Resources.GlobalString.SESSION_CART] as Dictionary<int, int>;

            if (cart != null)
            {
                string PaymentSRu=null;
                string PaymentSEn = null;

                //Установка выбраной системы оплаты
                //Setting the selected payment system
                if (PaymentSys == "1")
                {
                    PaymentSRu = Resources.ProductAndCRUD.InternalPaymentSystemRu;
                    PaymentSEn = Resources.ProductAndCRUD.InternalPaymentSystemEn;
                }
                else {
                    PaymentSRu = Resources.ProductAndCRUD.CreditCardRu;
                    PaymentSEn = Resources.ProductAndCRUD.CreditCardEn;
                }

                int iOrderStatusesNumber = orderStatusRepository.List().Count();
                string orderStatusRu = orderStatusRepository.List().First().NameRu;
                string orderStatusEn = orderStatusRepository.List().First().NameEn;
                Order or = null;

                if (!User.Identity.IsAuthenticated)
                {
                    // Заполнение заказа незарегистрированым пользователем
                    //Filling order unregistered users
                    or = of.OrderFillingUnknown(LastName, FirstName, Phone, Address, Email, PaymentSRu, PaymentSEn,
                        iOrderStatusesNumber, orderStatusRu, orderStatusEn);
                }
                else
                {
                    //Заполнение заказа зарегистрированым пользователем
                    //Filling order registered users
                    or = of.OrderFillingProfile(User.Identity.Name, PaymentSRu, PaymentSEn, iOrderStatusesNumber, orderStatusRu, orderStatusEn);
                }

                orderRepository.Insert(or);
                orderRepository.Save();
                OrderID = or.ID;

                //перечисление добавленных товаров
                //enumeration added products
                foreach (int key in cart.Keys)
                {
                    var product = productRepository.Find(key);

                    if (User.Identity.IsAuthenticated)
                    {
                        product.Price = User.IsInRole(E_shop.Constants.ROLE_USER) ? product.Price * 0.95m : product.Price * 0.9m;
                    }

                    //
                    product.CurrentBalance--;
                    productRepository.Save();

                    UserProfile profileAdmin = new UserProfile(Resources.GlobalString.ADMIN_NAME);
                    var profit = 0.0m;

                    if (PaymentSys.Equals("1"))
                    {
                        if (profile.Money > (decimal)product.Price * cart[key])
                        {
                            profile.Money = profile.Money - (decimal)product.Price * cart[key];
                            profile.Save();

                            profileAdmin.Money = profileAdmin.Money + (0.5m * (decimal)(product.Price - product.PurchasePrice) * cart[key]);

                            //Записать в отчет прибыль с заказа
                            //written to the database profit
                            profit = (0.5m * (decimal)(product.Price - product.PurchasePrice) * cart[key]);
                        }
                        else return RedirectToAction("Index");
                    }
                    else
                    {
                        profileAdmin.Money = profileAdmin.Money + (0.1m * (decimal)(product.Price - product.PurchasePrice));
                    }

                    // Заполение элементов заказа OrderItem
                    //Filling in the order about the product
                    var orit = oif.OrderItemFillingMore(OrderID, key, product.NameRu, product.NameEn, cart[key], product.Price, profit); //, profit
                    orderItemRepository.Insert(orit);
                    orderItemRepository.Save();

                    profileAdmin.Save();

                    //Если была совершена покупка более чем установленная цена то он получает статус VIP
                    //If they were purchased more than the fixed price he will receive VIP status
                    if (User.Identity.IsAuthenticated && orderItem.Number * orderItem.Price > 30900)
                    {
                        if (Roles.IsUserInRole(User.Identity.Name, Constants.ROLE_USER))
                            Roles.RemoveUserFromRole(User.Identity.Name, Constants.ROLE_USER);
                        if (!Roles.IsUserInRole(User.Identity.Name, Constants.ROLE_VIPUSER))
                            Roles.AddUserToRole(User.Identity.Name, Constants.ROLE_VIPUSER);
                    }
                }

                Session.Remove(Resources.GlobalString.SESSION_CART);
            }

            return View("ThankYou");
        }