1
0
mirror of https://github.com/bitwarden/server.git synced 2025-01-21 21:41:21 +01:00

Typed ids as guids in repositories. Removed unused repo methods.

This commit is contained in:
Kyle Spearrin 2016-03-09 18:11:52 -05:00
parent 994f27ff40
commit 8d57b21f97
8 changed files with 11 additions and 24 deletions

View File

@ -36,7 +36,7 @@ namespace Bit.Api.Controllers
}
[HttpGet("")]
public async Task<ListResponseModel<FolderResponseModel>> Get(bool dirty = false)
public async Task<ListResponseModel<FolderResponseModel>> Get()
{
var folders = await _folderRepository.GetManyByUserIdAsync(User.GetUserId());
return new ListResponseModel<FolderResponseModel>(folders.Select(f => new FolderResponseModel(f)));

View File

@ -42,9 +42,9 @@ namespace Bit.Api.Controllers
}
[HttpGet("")]
public async Task<ListResponseModel<SiteResponseModel>> Get(bool dirty = false, string[] expand = null)
public async Task<ListResponseModel<SiteResponseModel>> Get(string[] expand = null)
{
var sites = await _siteRepository.GetManyByUserIdAsync(User.GetUserId(), dirty);
var sites = await _siteRepository.GetManyByUserIdAsync(User.GetUserId());
var responses = sites.Select(s => new SiteResponseModel(s)).ToList();
await ExpandManyAsync(sites, responses, expand, null);

View File

@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Identity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.OptionsModel;
using Bit.Core.Domains;
using Microsoft.AspNet.Authentication.JwtBearer;
namespace Bit.Core.Identity

View File

@ -8,6 +8,5 @@ namespace Bit.Core.Repositories
{
Task<Folder> GetByIdAsync(string id, string userId);
Task<ICollection<Folder>> GetManyByUserIdAsync(string userId);
Task<ICollection<Folder>> GetManyByUserIdAsync(string userId, bool dirty);
}
}

View File

@ -9,6 +9,5 @@ namespace Bit.Core.Repositories
{
Task<Site> GetByIdAsync(string id, string userId);
Task<ICollection<Site>> GetManyByUserIdAsync(string userId);
Task<ICollection<Site>> GetManyByUserIdAsync(string userId, bool dirty);
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
@ -32,16 +33,11 @@ namespace Bit.Core.Repositories.SqlServer
{
var results = await connection.QueryAsync<FolderTableModel>(
$"[{Schema}].[{Table}_ReadByUserId]",
new { UserId = userId },
new { UserId = new Guid(userId) },
commandType: CommandType.StoredProcedure);
return results.Select(f => f.ToDomain()).ToList();
}
}
public async Task<ICollection<Folder>> GetManyByUserIdAsync(string userId, bool dirty)
{
return await GetManyByUserIdAsync(userId);
}
}
}

View File

@ -33,7 +33,7 @@ namespace Bit.Core.Repositories.SqlServer
{
var results = await connection.QueryAsync<TModel>(
$"[{Schema}].[{Table}_ReadById]",
new { Id = id },
new { Id = new Guid(id) },
commandType: CommandType.StoredProcedure);
var model = results.FirstOrDefault();
@ -96,7 +96,7 @@ namespace Bit.Core.Repositories.SqlServer
{
await connection.ExecuteAsync(
$"[{Schema}].[{Table}_DeleteById]",
new { Id = id },
new { Id = new Guid(id) },
commandType: CommandType.StoredProcedure);
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
@ -32,16 +33,11 @@ namespace Bit.Core.Repositories.SqlServer
{
var results = await connection.QueryAsync<SiteTableModel>(
$"[{Schema}].[{Table}_ReadByUserId]",
new { UserId = userId },
new { UserId = new Guid(userId) },
commandType: CommandType.StoredProcedure);
return results.Select(s => s.ToDomain()).ToList();
}
}
public async Task<ICollection<Site>> GetManyByUserIdAsync(string userId, bool dirty)
{
return await GetManyByUserIdAsync(userId);
}
}
}