This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Util;
|
||||
|
||||
|
||||
namespace AyaNova.Biz
|
||||
@@ -21,10 +16,10 @@ namespace AyaNova.Biz
|
||||
/// <param name="newEvent"></param>
|
||||
/// <param name="ct"></param>
|
||||
/// <returns></returns>
|
||||
internal static void LogEventToDatabaseAndSaveEntireContext(Event newEvent, AyContext ct)
|
||||
internal static async Task LogEventToDatabaseAsync(Event newEvent, AyContext ct)
|
||||
{
|
||||
ct.Event.Add(newEvent);
|
||||
ct.SaveChanges();
|
||||
await ct.Event.AddAsync(newEvent);
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +33,11 @@ namespace AyaNova.Biz
|
||||
/// <param name="ayId"></param>
|
||||
/// <param name="textra"></param>
|
||||
/// <param name="ct"></param>
|
||||
internal static void DeleteObject(long userId, AyaType ayType, long ayId, string textra, AyContext ct)
|
||||
internal static async Task DeleteObjectLogAsync(long userId, AyaType ayType, long ayId, string textra, AyContext ct)
|
||||
{
|
||||
ct.Database.ExecuteSqlInterpolated($"delete from aevent where aytype = {ayType} and ayid={ayId}");
|
||||
ct.Event.Add(new Event(userId, ayId, ayType, AyaEvent.Deleted, textra));
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from aevent where aytype = {ayType} and ayid={ayId}");
|
||||
await ct.Event.AddAsync(new Event(userId, ayId, ayType, AyaEvent.Deleted, textra));
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,7 +49,7 @@ namespace AyaNova.Biz
|
||||
//This is also an example of conditional where statements
|
||||
|
||||
//Set up the query
|
||||
var q = ct.Event.Select(m => m);
|
||||
var q = ct.Event.Select(m => m).AsNoTracking();
|
||||
|
||||
q = q.Where(m => m.AyId == opt.AyId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user