Update StatsByByAircraft
This commit is contained in:
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(StatsByAircraft newStats)
|
||||
public int Add(IEnumerable<StatsByAircraft> newStats)
|
||||
{
|
||||
int result;
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp.AsInt32;
|
||||
foreach (var newStat in newStats)
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -37,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
public StatsByAircraft GetAll(User user)
|
||||
public IEnumerable<StatsByAircraft> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.SingleOrDefault();
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(StatsByAircraft stats)
|
||||
public bool Update(IEnumerable<StatsByAircraft> updatedStats, User user)
|
||||
{
|
||||
return _col.Update(stats);
|
||||
Delete(user);
|
||||
var tmp = Add(updatedStats);
|
||||
|
||||
return tmp != 0;
|
||||
}
|
||||
|
||||
public bool Delete(User user)
|
||||
{
|
||||
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||
return tmp != 0;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
Reference in New Issue
Block a user