Exemple #1
0
        public JsonResult CreateUser(UserCreate model)
        {
            User userdb = UserRepository.Get(u => u.UserName == model.Email).SingleOrDefault();
            if (userdb == null)
            {
                FormsAuthentication.SetAuthCookie(model.Email, false/* createPersistentCookie */);
                User user = new User()
                {
                    UserName = model.Email,
                    Email = model.Email,
                    Password = EncodePassword(model.Password)
                };
                UserRepository.SaveOrUpdate(user);
                if (model.Email == "*****@*****.**")
                {
                    user.Role.IsAdmin = true;
                    UserRepository.SaveOrUpdate(user);
                    return Json(DefaulAdminCabinet);
                }
            }
            else if (CheckPassword(userdb.Password, model.Password))
            {
                FormsAuthentication.SetAuthCookie(model.Email, false/* createPersistentCookie */);
                userdb.Orders = null;
                UserRepository.SaveOrUpdate(userdb);
                if (userdb.Role.IsAdmin)
                {
                    return Json(DefaulAdminCabinet);
                }
                if (userdb.Role.IsAuthor)
                {
                    return Json(DefaulAuthorCabinet);
                }

            }
            return Json("\\");
        }
Exemple #2
0
 private Order NottifyOnProcassOrder(Order order, User user)
 {
     order.ProcessDateTime = DateTime.Now.ToString();
     order.OrderStatus = new OrderStatus() { IsInProgress = true };
     order = OrdersRepository.SaveOrUpdate(order);
     NotificateEmployee(order);
     user.Orders.Remove(order);
     user.OrdersHistory.Add(order);
     UserRepository.SaveOrUpdate(user);
     return order;
 }
Exemple #3
0
        private Order AddOrderToBascet(User user, Product product)
        {
            Order order = new Order()
            {
                Email = !string.IsNullOrEmpty(user.Email) ? user.Email : "*****@*****.**",
                User = user,
                Product = product,
                Comments = DefaultComments
            };

            order = OrdersRepository.SaveOrUpdate(order);

            user.AddOrder(order);
            UserRepository.SaveOrUpdate(user);

            return order;
        }