Ejemplo n.º 1
0
        /// <summary>
        /// 更改用户资料
        /// </summary>
        /// <param name="user"></param>
        public (bool Status, string Message) UpdateUser(Sys_UserMapping model, Guid modifier)
        {
            var user = _dbContext.Sys_User.Find(model.Id);

            if (user == null)
            {
                Fail("用户不存在");
            }
            string oldJson = JsonConvert.SerializeObject(user);

            user.MobilePhone = model.MobilePhone;
            user.Email       = model.Email;
            user.Name        = model.Name;

            string newJson = JsonConvert.SerializeObject(user);

            _dbContext.SaveChanges();
            //记录日志
            _activityLogService.InsertedEntity <Entities.Sys_User>(model.Id, oldJson, newJson, modifier);
            RemoveCache(user.Id);
            return(Success("修改成功"));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public (bool Status, string Message) AddBucket(Bucket item)
 {
     lock (lockObj)
     {
         if (!_dbContext.Bucket.Any(o => o.Name == item.Name))
         {
             string newLog = JsonConvert.SerializeObject(item);
             _dbContext.Bucket.Add(item);
             _dbContext.SaveChanges();
             _activityLogService.InsertedEntity <Entities.Bucket>(item.Id, null, newLog, item.Creator);
             _cacheManager.Remove(MODEL_KEY);
             return(Success("添加成功"));
         }
         return(Fail("名称已存在"));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public (bool Status, string Message) AddRole(Entities.Sys_Role role)
        {
            lock (lockObj)
            {
                if (_dbContext.Sys_Role.Any(o => o.Name == role.Name))
                {
                    return(Fail("角色名称已经存在"));
                }
                _dbContext.Sys_Role.Add(role);
                _dbContext.SaveChanges();

                string newJson = JsonConvert.SerializeObject(role);
                _activityLogService.InsertedEntity <Entities.Sys_Role>(role.Id, null, newJson, role.Creator);
                RemoveCahce();
                return(Success("添加成功"));
            }
        }