DocSas/PropertyService.Domain/ModelView/Roles/RoleProvider.cs
/// <summary>
/// save available role as an asynchronous operation.
/// </summary>
/// <param name="roleVM">The role vm.</param>
/// <returns>Task&lt;DSCResponse&gt;.</returns>
save available role as an asynchronous operation.
save available role as an asynchronous operation .
public async Task<DSCResponse> SaveAvailableRoleAsync(AvailableRoleVM roleVM)
        {
            var msg = new Dictionary<string, string>();
            var response = new DSCResponse();
            var issuccess = false;
            if (roleVM.Id == Guid.Empty)
            {
                var management = await _appCommon.GetManagementUserAsync(roleVM.CreatorUserId);
                if (management != null)
                {
                    var role = new AvailableRole()
                    {
                        Title = roleVM.Title,
                        RoleDesc = roleVM.RoleDesc,
                        ManagementUserId = management.Id,
                        HasManagementRights = roleVM.HasManagementRights,
                        IsValid = true
                    };
                    await _availableRoleRepo.AddAsync(role);
                    issuccess = true;
                }
            }
            else
            {
                var role = await _availableRoleRepo.GetSingleAsync(x => x.Id == roleVM.Id);
                if (role != null)
                {
                    role.Title = roleVM.Title;
                    role.RoleDesc = roleVM.RoleDesc;
                    role.HasManagementRights = roleVM.HasManagementRights;
                    role.IsValid = roleVM.IsValid;
                    await _availableRoleRepo.ModifyAsync(role);
                    issuccess = true;
                }
            }
            response.ResponseData = issuccess;
            response.ErrorMessage = msg;
            return response;
        }
public async Task < DSCResponse > SaveAvailableRoleAsync ( AvailableRoleVM roleVM ) { var msg = new Dictionary < string , string > ( ) ; var response = new DSCResponse ( ) ; var issuccess = false ; if ( roleVM . Id == Guid . Empty ) { var management = await _appCommon . GetManagementUserAsync ( roleVM . CreatorUserId ) ; if ( management != null ) { var role = new AvailableRole ( ) { Title = roleVM . Title , RoleDesc = roleVM . RoleDesc , ManagementUserId = management . Id , HasManagementRights = roleVM . HasManagementRights , IsValid = true } ; await _availableRoleRepo . AddAsync ( role ) ; issuccess = true ; } } else { var role = await _availableRoleRepo . GetSingleAsync ( x => x . Id == roleVM . Id ) ; if ( role != null ) { role . Title = roleVM . Title ; role . RoleDesc = roleVM . RoleDesc ; role . HasManagementRights = roleVM . HasManagementRights ; role . IsValid = roleVM . IsValid ; await _availableRoleRepo . ModifyAsync ( role ) ; issuccess = true ; } } response . ResponseData = issuccess ; response . ErrorMessage = msg ; return response ; }
save available role as an asynchronous operation.
save available role as an asynchronous operation .
None
roleVM
AvailableRoleVM
The role vm.
The role vm .