/// <summary> /// Add a rank for the given server /// </summary> /// <param name="serverId">The id of the sercer</param> /// <param name="roleId">The id of the rank to add</param> /// <returns></returns> public async Task AddRank(ulong serverId, ulong roleId) { var server = await _serverRepository.GetByServerId(serverId); if (server == null) { await _serverRepository.AddAsync(new Server { GuildId = serverId, Prefix = _settings.DefaultPrefix }); } await _rankRepository.AddAsync(new Rank { RoleId = roleId, ServerId = server.Id }); }
public async Task <SaveRankResponse> SaveAsync(Rank rank) { try { await _rankRepository.AddAsync(rank); await _unitOfWork.CompleteAsync(); return(new SaveRankResponse(rank)); } catch (Exception ex) { // Do some logging stuff return(new SaveRankResponse($"An error occurred when saving the Department: {ex.Message}")); } }