mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
Modified the adding of request to update the model with the added ID
This commit is contained in:
parent
f7b32ca9dc
commit
5dd9857011
1 changed files with 8 additions and 4 deletions
|
@ -44,12 +44,16 @@ namespace PlexRequests.Core
|
||||||
private IRequestRepository Repo { get; }
|
private IRequestRepository Repo { get; }
|
||||||
public long AddRequest(int providerId, RequestedModel model)
|
public long AddRequest(int providerId, RequestedModel model)
|
||||||
{
|
{
|
||||||
var latestId = Repo.GetAll().OrderByDescending(x => x.Id).Select(x => x.Id).FirstOrDefault();
|
|
||||||
var newId = latestId + 1;
|
|
||||||
model.Id = newId;
|
|
||||||
var entity = new RequestBlobs { Type = model.Type, Content = ReturnBytes(model), ProviderId = model.ProviderId};
|
var entity = new RequestBlobs { Type = model.Type, Content = ReturnBytes(model), ProviderId = model.ProviderId};
|
||||||
|
|
||||||
return Repo.Insert(entity);
|
var id = Repo.Insert(entity);
|
||||||
|
|
||||||
|
model.Id = (int)id;
|
||||||
|
|
||||||
|
entity = new RequestBlobs { Type = model.Type, Content = ReturnBytes(model), ProviderId = model.ProviderId, Id = (int)id};
|
||||||
|
var result = Repo.Update(entity);
|
||||||
|
|
||||||
|
return result ? id : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckRequest(int providerId)
|
public bool CheckRequest(int providerId)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue