예제 #1
0
        public ActionResult Add(SysAdminInertBasicInfoInput model)
        {
            if (Request["Enable"] != null && Request["Enable"].ToString() == "on")
            {
                model.Enable = true;
            }

            _sysManagerService.Add(model);

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public void Add(SysAdminInertBasicInfoInput model)
        {
            if (model == null)
            {
                throw new JIFException("信息不能为空");
            }

            if (string.IsNullOrWhiteSpace(model.Account) ||
                string.IsNullOrWhiteSpace(model.Password) ||
                string.IsNullOrWhiteSpace(model.Email))
            {
                throw new JIFException("信息不完整");
            }

            var exists = _sysAdminRepository.Table.Any(d => model.Account.ToLower().Trim() == d.Account.ToLower().Trim());

            if (exists)
            {
                throw new JIFException("帐号: " + model.Account + ", 已存在");
            }

            var now = DateTime.Now;

            var entity = new SysAdmin
            {
                Account      = model.Account,
                Email        = model.Email,
                CellPhone    = model.CellPhone,
                Password     = EncyptPwd(model.Password, now),
                Enable       = model.Enable,
                CreateTime   = now,
                CreateUserId = _workContext.CurrentUser.Id
            };

            _sysAdminRepository.Insert(entity);
        }