示例#1
0
        // GET: Install
        public ActionResult Index()
        {
            var data           = Encoding.ASCII.GetBytes("1qaz@WSX");
            var md5            = new MD5CryptoServiceProvider();
            var md5data        = md5.ComputeHash(data);
            var hashedPassword = Encoding.ASCII.GetString(md5data);

            UserAccount user = new UserAccount();

            user.Address      = "";
            user.Email        = "*****@*****.**";
            user.UserName     = "******";
            user.FirstName    = "مدیر";
            user.LastName     = "ارشد";
            user.MobilePhone  = "";
            user.Password     = hashedPassword;
            user.Phone        = "";
            user.RegisterDate = DateTime.Now;
            user.State        = 1;
            user.Add();
            return(View());
        }
示例#2
0
        public ActionResult Create(string userName, string password, string firstName, string lastName, string state, string address, string email, string phone, string mobilePhone,
                                   string cart, string concatus, string customers, string news, string faq, string slider, string ticket, string order, string payrequest, string receipt, string transactions, string users, string settings)
        {
            string permissions = "";
            int    stat        = 0;

            if (HasPermission("[users]", ref permissions, ref stat))
            {
                return(RedirectToAction("AccessDeny"));
            }
            ViewBag.permissions = permissions;
            ViewBag.stat        = stat;

            ViewBag.Title = "اطلاعات کاربر";
            UserAccount tk = new UserAccount();

            try
            {
                System.Collections.Specialized.NameValueCollection val = Request.Form;
                var data           = Encoding.ASCII.GetBytes(password);
                var md5            = new MD5CryptoServiceProvider();
                var md5data        = md5.ComputeHash(data);
                var hashedPassword = Encoding.ASCII.GetString(md5data);

                string permission = (!string.IsNullOrEmpty(cart) ? "[cart]" : "");
                permission += (!string.IsNullOrEmpty(concatus) ? "[concatus]" : "");
                permission += (!string.IsNullOrEmpty(customers) ? "[customers]" : "");
                permission += (!string.IsNullOrEmpty(news) ? "[news]" : "");
                permission += (!string.IsNullOrEmpty(faq) ? "[faq]" : "");
                permission += (!string.IsNullOrEmpty(slider) ? "[slider]" : "");
                permission += (!string.IsNullOrEmpty(ticket) ? "[ticket]" : "");
                permission += (!string.IsNullOrEmpty(order) ? "[order]" : "");
                permission += (!string.IsNullOrEmpty(payrequest) ? "[payrequest]" : "");
                permission += (!string.IsNullOrEmpty(receipt) ? "[receipt]" : "");
                permission += (!string.IsNullOrEmpty(transactions) ? "[transactions]" : "");
                permission += (!string.IsNullOrEmpty(users) ? "[users]" : "");
                permission += (!string.IsNullOrEmpty(settings) ? "[settings]" : "");

                tk.FirstName    = firstName;
                tk.LastName     = lastName;
                tk.State        = int.Parse(state);
                tk.Address      = address;
                tk.Email        = email;
                tk.UserName     = userName;
                tk.Password     = hashedPassword;
                tk.Phone        = phone;
                tk.MobilePhone  = mobilePhone;
                tk.RegisterDate = DateTime.Now;
                tk.Permission   = permission;
                tk.Add();
                return(RedirectToAction("", "Users"));
            }
            catch (Exception ex)
            {
                ErrorLog log = new ErrorLog();
                log.Description = ex.Message;
                if (ex.InnerException != null)
                {
                    log.Description += ";" + ex.Message;
                }
                log.ErrorDate = DateTime.Now;
                log.Add();
            }
            return(View(tk));
        }