Esempio n. 1
0
        public async Task <JsonResult> Update(Envs model)
        {
            var result = new BaseResult();
            var list   = await _envService.GetList();

            var nameList = list.Where(s => s.Name == model.Name);
            var oldModel = list.Where(s => s.Id == model.Id).FirstOrDefault();

            if (nameList != null && nameList.Count() > 0 && nameList.FirstOrDefault().Id != model.Id)
            {
                result.IsSuccess = false;
                result.ErrorMsg  = "该环境名称已经存在";
            }
            else
            {
                await _permissionService.BatchUpdatePer(oldModel.Name, model.Name, PermissionType.Env);

                result.IsSuccess = await _envService.Update(model);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public async Task <JsonResult> Update(Apps model)
        {
            var result = new BaseResult();
            var list   = await _appService.GetList();

            var nameList = list.Where(s => string.Equals(s.Name, model.Name, StringComparison.OrdinalIgnoreCase));
            var oldModel = list.Where(s => s.Id == model.Id).FirstOrDefault();

            if (nameList != null && nameList.Count() > 0 && nameList.FirstOrDefault().Id != model.Id)
            {
                result.IsSuccess = false;
                result.ErrorMsg  = "该App名称已经存在";
            }
            else
            {
                await _permissionService.BatchUpdatePer(oldModel.Name, model.Name, PermissionType.App);

                result.IsSuccess = await _appService.Update(model);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }