This commit is contained in:
@@ -1,13 +1,8 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using EnumsNET;
|
||||
using AyaNova.Util;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AyaNova.Biz
|
||||
{
|
||||
@@ -63,7 +58,7 @@ namespace AyaNova.Biz
|
||||
internal async Task<NotifySubscription> DuplicateAsync(long id)
|
||||
{
|
||||
|
||||
NotifySubscription dbObject = await GetAsync(id, false);
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
@@ -87,7 +82,7 @@ namespace AyaNova.Biz
|
||||
//
|
||||
internal async Task<NotifySubscription> GetAsync(long id, bool logTheGetEvent = true)
|
||||
{
|
||||
var ret = await ct.NotifySubscription.SingleOrDefaultAsync(z => z.Id == id && z.UserId == UserId);
|
||||
var ret = await ct.NotifySubscription.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id && z.UserId == UserId);
|
||||
if (logTheGetEvent && ret != null)
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
||||
return ret;
|
||||
@@ -100,19 +95,16 @@ namespace AyaNova.Biz
|
||||
{
|
||||
//TODO: Must remove all prior events and replace them
|
||||
|
||||
NotifySubscription dbObject = await ct.NotifySubscription.SingleOrDefaultAsync(z => z.Id == putObject.Id);
|
||||
var dbObject = await GetAsync(putObject.Id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
return null;
|
||||
}
|
||||
NotifySubscription SnapshotOfOriginalDBObj = new NotifySubscription();
|
||||
CopyObject.Copy(dbObject, SnapshotOfOriginalDBObj);
|
||||
CopyObject.Copy(putObject, dbObject, "Id");//can update serial
|
||||
dbObject.Tags = TagBiz.NormalizeTags(dbObject.Tags);
|
||||
|
||||
ct.Entry(dbObject).OriginalValues["Concurrency"] = putObject.Concurrency;
|
||||
await ValidateAsync(dbObject);
|
||||
putObject.Tags = TagBiz.NormalizeTags(putObject.Tags);
|
||||
await ValidateAsync(putObject);
|
||||
if (HasErrors) return null;
|
||||
ct.Replace(dbObject, putObject);
|
||||
if (HasErrors) return null;
|
||||
try
|
||||
{
|
||||
@@ -127,7 +119,7 @@ namespace AyaNova.Biz
|
||||
return null;
|
||||
}
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
|
||||
return dbObject;
|
||||
}
|
||||
|
||||
@@ -141,7 +133,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
try
|
||||
{
|
||||
NotifySubscription dbObject = await ct.NotifySubscription.SingleOrDefaultAsync(z => z.Id == id);
|
||||
var dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
|
||||
Reference in New Issue
Block a user