public ActionResult Add(Staff model)
        {
            model.IsDeleted = false;
            model.CreatedAt = model.UpdatedAt = DateTime.Now;
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Email == "" || model.Email == null)
                    {
                        model.Email = model.UserName;
                    }
                    model.Password = SimpleEncrypt.Encrypt(model.Password, true);
                    db.Staffs.Add(model);
                    db.SaveChanges();
                    return(Content(javasctipt_add("/Staff", "Thêm dữ liệu thành công")));
                }
                catch (Exception)
                {
                    return(Content(javasctipt_add("/Staff", "Thêm dữ liệu thất bại")));
                }
            }
            var status = StatusUtils.GetSettingStatus();

            ViewBag.IsActive = new SelectList(status, "Value", "Text", model.IsActive);
            ViewBag.RoleId   = new SelectList(db.Roles.Where(n => n.Name.Contains("Better")), "Id", "Name", model.RoleId);
            ViewBag.Gender   = new SelectList(StatusUtils.GetGender(), "Value", "Text", model.Gender);
            return(Content(javasctipt_add("/Staff", "Thêm dữ liệu thất bại")));
        }
        public ActionResult Edit(Staff model, string ReNewPassword)
        {
            model.IsDeleted = false;
            model.UpdatedAt = DateTime.Now;
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Email == "" || model.Email == null)
                    {
                        model.Email = model.UserName;
                    }
                    if (ReNewPassword != null && ReNewPassword.Trim().Length > 0)
                    {
                        model.Password = SimpleEncrypt.Encrypt(ReNewPassword, true);
                    }
                    db.Entry(model).State = EntityState.Modified;
                    db.SaveChanges();
                    return(Content(javasctipt_add("/Staff", "Cập nhật dữ liệu thành công")));
                }
                catch (Exception)
                {
                    return(Content(javasctipt_add("/Staff", "Cập nhật dữ liệu thất bại")));
                }
            }
            ViewBag.RoleId = new SelectList(db.Roles.Where(n => n.Name.Contains("Better")), "Id", "Name", model.RoleId);
            var status = StatusUtils.GetSettingStatus();

            ViewBag.IsActive = new SelectList(status, "Value", "Text", model.IsActive);
            ViewBag.Gender   = new SelectList(StatusUtils.GetGender(), "Value", "Text", model.Gender);
            return(Content(javasctipt_add("/Staff", "Cập nhật dữ liệu thất bại")));
        }
示例#3
0
        public ActionResult Add(PcAndRole model)
        {
            Utility.ReturnData <string> returnData = new Utility.ReturnData <string>();
            long      count   = bll.GetQueryCount(x => x.UserName == model.UserName && x.Status != 1);
            UserBasic ubModel = new UserBasic();

            ubModel.NickName     = model.UserName;
            ubModel.UserType     = 1;
            ubModel.AddTime      = DateTime.Now;
            ubModel.EnterpriseID = LoginUser.UserBasic.EnterpriseID;
            long   id      = ubBll.AddAndGetId(ubModel);
            UserPC upModel = new UserPC();

            upModel.UserName       = model.UserName;
            upModel.UserBasicID    = id;
            upModel.RoleID         = model.RoleID;
            upModel.PCType         = 1;
            upModel.AddTime        = DateTime.Now;
            upModel.PassWord       = SimpleEncrypt.SaltMD5(model.PassWord.Replace(" ", ""));
            upModel.AddUserBasicID = LoginUser.UserBasicID;
            upModel.Status         = 0;
            returnData             = bll.AddUserPc(upModel);
            if (returnData.Status == false)
            {
                ubBll.Delete(s => s.ID == id);
                return(Content(returnData.Message));
            }
            return(Content(returnData.Message));
        }
示例#4
0
        public ActionResult FirstLogin(string name, string pwd, string num)
        {
            ReturnData <string> ret   = new ReturnData <string>();
            AgentBll            aBll  = new AgentBll();
            UserBasicBll        uBll  = new UserBasicBll();
            UserPCBll           pcBll = new UserPCBll();

            Agent     aModel  = aBll.GetModelByPhone(num);
            UserBasic uModel  = new UserBasic();
            UserPC    pcModel = new UserPC();

            uModel.NickName     = name;
            uModel.UserType     = 1;
            uModel.EnterpriseID = aModel.EnterpriseID;
            uModel.AddTime      = DateTime.Now;
            long id = uBll.AddAndGetId(uModel);

            pcModel.UserBasicID    = id;
            pcModel.PassWord       = SimpleEncrypt.SaltMD5(pwd.Replace(" ", ""));
            pcModel.PCType         = 2;
            pcModel.RoleID         = aModel.ID;
            pcModel.Status         = 0;
            pcModel.UserName       = name;
            pcModel.AddTime        = DateTime.Now;
            pcModel.AddUserBasicID = 0;
            ret = pcBll.AddUserPc(pcModel);
            if (ret.Status == true)
            {
                aModel.Status = 0;
                aBll.EditAgent(aModel);
                return(Content(ret.Message));
            }
            return(Content(ret.Message));
        }
示例#5
0
        public ActionResult EditPwd(string oldpwd, string pwd)
        {
            Utility.ReturnData <string> ret = new Utility.ReturnData <string>();
            long   id       = LoginUser.UserBasicID;
            UserPC model    = bll.GetModelById(id);
            string checkpwd = SimpleEncrypt.SaltMD5(oldpwd.Replace(" ", ""));

            if (model.PassWord != checkpwd)
            {
                return(Content("原始密码不正确!"));
            }
            model.PassWord = SimpleEncrypt.SaltMD5(pwd.Replace(" ", ""));
            bll.Update(model);

            return(Content("修改成功!"));
        }
示例#6
0
        public ActionResult ChangePwd(string pwd, int id)
        {
            Utility.ReturnData <string> returnData = new Utility.ReturnData <string>();
            UserPC model = bll.GetModelById(id);

            model.PassWord = SimpleEncrypt.SaltMD5(pwd.Replace(" ", ""));
            returnData     = bll.UpdateUserPc(model);
            if (returnData.Message == "编辑成功!")
            {
                return(Content("重置成功!"));
            }
            else
            {
                return(Content(returnData.Message));
            }
        }
        public ActionResult UpdateInfo(Staff staff, string ReNewPassword)
        {
            staff.IsDeleted = false;
            staff.IsActive  = true;
            staff.UpdatedAt = DateTime.Now;

            if (ModelState.IsValid)
            {
                try
                {
                    var upImage = Request.Files["upImage"];
                    if (upImage.ContentLength > 0 && upImage != null)
                    {
                        string fileName = upImage.FileName.DoiTenHinh();
                        upImage.SaveAs(Server.MapPath("~/images/Staff/" + fileName));
                        staff.Avatar = fileName;
                    }
                    if (ReNewPassword != null && ReNewPassword.Trim().Length > 0)
                    {
                        staff.Password = SimpleEncrypt.Encrypt(ReNewPassword, true);
                    }
                    db.Entry(staff).State = EntityState.Modified;
                    db.SaveChanges();
                    Session["AccBetterLife"] = staff;
                    #region create cookies
                    HttpCookie ckiUser = new HttpCookie("CkBetterLife");
                    ckiUser["Id"]   = staff.UserName;
                    ckiUser["Pw"]   = SimpleEncrypt.Encrypt(staff.Password, true);
                    ckiUser.Expires = DateTime.Now.AddHours(24);
                    Response.Cookies.Add(ckiUser);
                    #endregion
                    TempData["Message"] = "Cập nhật thông tin thành công";
                    return(PartialView("~/views/Message/Add.cshtml"));
                }
                catch (Exception)
                {
                    ModelState.AddModelError("error", "Có lỗi xảy ra, vui lòng kiểm tra lại dữ liệu");
                    TempData["Message"] = "Có lỗi xảy ra, vui lòng kiểm tra lại dữ liệu";
                }
            }
            ViewBag.RoleId = new SelectList(db.Roles.Where(n => n.Name.Contains("Better")), "Id", "Name", staff.RoleId);
            return(View(staff));
        }
示例#8
0
 public void Setup()
 {
     helper = new SimpleEncrypt();
     text   = "hello world";
 }
示例#9
0
 public ActionResult Index(LoginModel loginModel)
 {
     ViewBag.role = new SelectList(SelectListUtils.RoleLogin(), "Value", "Text", loginModel.role);
     try
     {
         //login step hight agency
         var userAgency = db.AgencyAccounts.Single(n => n.UserName == loginModel.userName && n.IsActive == true);
         if (userAgency.Password == SimpleEncrypt.Encrypt(loginModel.password, true))
         {
             Session["AccBetterLife"] = userAgency;
             if (loginModel.reMember == true)
             {
                 #region create cookies
                 HttpCookie ckiUser = new HttpCookie("CkBetterLife");
                 ckiUser["Id"]   = userAgency.UserName;
                 ckiUser["Pw"]   = SimpleEncrypt.Encrypt(loginModel.password, true);
                 ckiUser.Expires = DateTime.Now.AddDays(24);
                 Response.Cookies.Add(ckiUser);
                 #endregion
             }
             //redirect app
             #region create cookies role
             HttpCookie ckiRoleLogin = new HttpCookie("ckiRoleLogin");
             ckiRoleLogin["ckiRoleLogin"] = "******";
             ckiRoleLogin.Expires         = DateTime.Now.AddDays(24);
             Response.Cookies.Add(ckiRoleLogin);
             #endregion
             return(Redirect("/Home"));
         }
         else
         {
             ViewBag.Message = " Sai thông tin đăng nhập";
             return(View("Index"));
         }
     }
     //login blf account
     catch
     {
         try
         {
             var user = db.Staffs.Single(n => n.UserName == loginModel.userName && n.IsActive == true);
             if (user.Password == SimpleEncrypt.Encrypt(loginModel.password, true))
             {
                 Session["AccBetterLife"] = user;
                 if (loginModel.reMember == true)
                 {
                     #region create cookies
                     HttpCookie ckiUser = new HttpCookie("CkBetterLife");
                     ckiUser["Id"]   = user.UserName;
                     ckiUser["Pw"]   = SimpleEncrypt.Encrypt(loginModel.password, true);
                     ckiUser.Expires = DateTime.Now.AddDays(24);
                     Response.Cookies.Add(ckiUser);
                     #endregion
                 }
                 //redirect app
                 #region create cookies role
                 HttpCookie ckiRoleLogin = new HttpCookie("ckiRoleLogin");
                 ckiRoleLogin["ckiRoleLogin"] = "******";
                 ckiRoleLogin.Expires         = DateTime.Now.AddDays(24);
                 Response.Cookies.Add(ckiRoleLogin);
                 #endregion
                 return(Redirect("/Security/Choose"));
             }
             else
             {
                 ViewBag.Message = " Sai thông tin đăng nhập";
                 return(View("Index"));
             }
         }
         catch (Exception ex)
         {
             ViewBag.Message = " Sai thông tin đăng nhập " + ex.Message;
             ViewBag.role    = new SelectList(SelectListUtils.RoleLogin(), "Value", "Text", loginModel.role);
             return(View("Index"));
         }
     }
 }
 public void OrderReady(CrossBot routine, string msg, string dodo)
 {
     msg = SanitizeForTwitch(msg);
     if (Settings.OrderWaitDestination == TwitchMessageDestination.Channel)
     {
         SendMessage($"I'm waiting for you @{Trader}! {msg}. Enter the number you whispered to me on https://berichan.github.io/GetDodoCode/?hash={SimpleEncrypt.SimpleEncryptToBase64(dodo, Password).MakeWebSafe()} to get your dodo code. Click this link, not an old one or someone else's.", Settings.OrderWaitDestination);
     }
     else if (Settings.OrderWaitDestination == TwitchMessageDestination.Whisper)
     {
         SendMessage($"I'm waiting for you @{Trader}! {msg}. Your Dodo code is {dodo}", Settings.OrderWaitDestination);
     }
 }