Exemplo n.º 1
0
        public ActionResult CreateAdminUser(AdminUser user)
        {
            int count = AdminUserServices.LoadEntities(u => u.Uid == user.Uid).Count();

            if (count > 0)
            {
                ViewData["message"] = "用户名已存在";
                return(View());
            }

            string pwd = user.Pwd;


            if (CurrentLoginUser.Uid != "admin")
            {
                return(Redirect("/Admin/Home"));
            }
            user.Pwd = CommonHelper.GetStringMD5(user.Pwd);
            AdminUserServices.Add(user);

            MyEmail email = new MyEmail();

            email.SendEmail = user.Email;
            email.Title     = "您在青职二货街的系统管理员账户已开通";
            email.Subject   = "青职二货街-系统管理员";
            string website = CommonHelper.GetWebSite();

            string html = "恭喜!您的青职二货街管理账户已开通! 用户名:" + user.Uid + ",密码:" + pwd + " 登录网址为" + website + "/others/adminlogin 。为了系统安全,请您及时修改密码。(此邮件由系统自动发出)";

            email.Content = html;

            EmailSendToAllAdmin.SendEmail(email);


            return(Redirect("/Admin/AdminUserList"));
        }
        public ActionResult OpenShop(ListShops shop, string IsCode, string IsKouHao)
        {
            ViewData["realname"]  = shop.RealName;
            ViewData["classname"] = shop.CalssName;
            ViewData["idcard"]    = shop.IdCard;

            if (IsCode != "1" || IsKouHao != "1")
            {
                ViewData["message"]    = "请按照步骤完成任务操作";
                ViewData["ShopStatus"] = "0";
                return(View());
            }


            string imagefull = string.Empty;

            #region 学生证
            HttpPostedFileBase jpeg_image_upload = Request.Files[0];

            //获取文件名
            string filename = Path.GetFileName(jpeg_image_upload.FileName);

            //获取文件类型
            string fileext = Path.GetExtension(filename);

            if (fileext == ".jpg" || fileext == ".png")
            {
                string guid = Guid.NewGuid().ToString();

                string bigdir = "/Upload/" + "big/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/";
                Directory.CreateDirectory(Path.GetDirectoryName(Server.MapPath(bigdir)));
                string full = bigdir + guid + "_大图" + fileext;
                jpeg_image_upload.SaveAs(Server.MapPath(full));
                imagefull = full;
            }
            #endregion
            shop.CardAddress = imagefull;


            if (string.IsNullOrEmpty(imagefull))
            {
                ViewData["message"]    = "请上传学生证照片";
                ViewData["ShopStatus"] = "0";
                return(View());
            }

            var shops = ListShopsServices.LoadEntities(u => u.UserInfoId == CurrentLoginUser.Id).FirstOrDefault();

            if (shops != null)
            {
                if (shops.Status == auditing)
                {
                    ViewData["message"]    = "您已提交开店申请,正在审核中,请耐心等候";
                    ViewData["ShopStatus"] = auditing;
                    return(View());
                }
                else if (shops.Status == success)
                {
                    ViewData["message"]    = "您已开通店铺,请进行使用吧";
                    ViewData["ShopStatus"] = success;
                    return(View());
                }
                else if (shops.Status == filed)
                {
                    var dbShop = ListShopsServices.LoadEntities(u => u.UserInfoId == CurrentLoginUser.Id).FirstOrDefault();

                    dbShop.SubTime     = DateTime.Now;
                    dbShop.Status      = auditing;
                    dbShop.IdCard      = shop.IdCard;
                    dbShop.CalssName   = shop.CalssName;
                    dbShop.CardAddress = shop.CardAddress;
                    dbShop.RealName    = shop.RealName;
                    ListShopsServices.Update(dbShop);
                }
            }
            else
            {
                shop.UserInfoId  = CurrentLoginUser.Id;
                shop.SubTime     = DateTime.Now;
                shop.Status      = auditing;
                shop.CardAddress = imagefull;
                ListShopsServices.Add(shop);
            }

            var adminList = AdminUserServices.LoadEntities(u => true).ToList();

            foreach (var item in adminList)
            {
                MyEmail email = new MyEmail();
                email.SendEmail = item.Email;
                email.Title     = CurrentLoginUser.Uid + "正在进行申请进行开店操作";
                email.Subject   = "青职二货街";
                //生成验证连接
                string website = CommonHelper.GetWebSite();
                //生成发送邮箱模版
                string html = System.IO.File.ReadAllText(Server.MapPath("/EmailTemp/OpenShops.html"));
                html = html.Replace("@website", website).Replace("@ids", shop.Id.ToString()).Replace("@RealName", shop.RealName).Replace("@IdCard", shop.IdCard).Replace("@ClassName", shop.CalssName).Replace("@imgsrc", website + shop.CardAddress);

                email.Content = html;

                EmailSendToAllAdmin.SendEmail(email);
            }


            ViewData["message"]    = "您已提交开店申请,正在审核中,请耐心等候";
            ViewData["ShopStatus"] = "-1";

            return(View());
        }