/// <summary>
        /// The add.
        /// </summary>
        /// <param name="roleInput">
        /// The role input.
        /// </param>
        public void Add(RoleInputDto roleInput)
        {
            Guard.ArgumentNotNull(() => roleInput);

            var toAdd = Mapper.Map<Role>(roleInput);

            using (var unitOfWork = EngineContext.Current.Resolve<ISkymateUnitOfWork>())
            {
                if (toAdd.ID == Guid.Empty)
                {
                    toAdd.ID = GuidHelper.GenerateGuid();
                }

                this.roleRepository.Add(toAdd);

                unitOfWork.Commit();
            }
        }
        /// <summary>
        /// The update.
        /// </summary>
        /// <param name="roleInput">
        /// The role input.
        /// </param>
        public void Update(RoleInputDto roleInput)
        {
            Guard.ArgumentNotNull(() => roleInput);
            Guard.ArgumentNotEmpty(() => roleInput.Id);

            using (var unitOfWork = EngineContext.Current.Resolve<ISkymateUnitOfWork>())
            {
                var toUpdate = this.roleRepository.GetByKey(roleInput.Id);
                toUpdate = Mapper.Map(roleInput, toUpdate);

                this.roleRepository.Update(toUpdate);

                unitOfWork.Commit();
            }
        }
 public async Task <AjaxResult> UpdateAsync([FromBody] RoleInputDto input)
 {
     return((await _roleContract.UpdateAsync(input)).ToAjaxResult());
 }
Exemple #4
0
 public async Task <AjaxResult> CreateAsync([FromBody] RoleInputDto dto)
 {
     return((await _roleManagerServices.AddRoleAsync(dto)).ToAjaxResult());
 }
Exemple #5
0
 public async Task <StatusResult> Update(RoleInputDto input)
 {
     return(await _roleService.UpdateAsync(input));
 }
Exemple #6
0
 public async Task <StatusResult> Add(RoleInputDto input)
 {
     return(await _roleService.AddAsync(input));
 }
 public ActionResult Edit(RoleInputDto[] dtos)
 {
     dtos.CheckNotNull("dtos" );
     OperationResult result = IdentityContract.EditRoles(dtos);
     return Json(result.ToAjaxResult());
 }
 public ActionResult Create()
 {
     var newRole = new RoleInputDto();
     return this.Json(OperationResult.Success(string.Empty, string.Empty, newRole), JsonRequestBehavior.AllowGet);
 }
        public ActionResult SaveRole(RoleInputDto roleInput)
        {
            if (!ModelState.IsValid)
            {
                return this.Json(OperationResult.Error("输入值有错误"));
            }

            try
            {
                if (roleInput.Id == Guid.Empty)
                {
                    this.roleService.Add(roleInput);
                }
                else
                {
                    this.roleService.Update(roleInput);
                }

                return this.Json(OperationResult.Success("保存成功"));
            }
            catch (Exception e)
            {
                return this.Json(OperationResult.Error("保存失败," + e.Message));
            }
        }