public async Task InvokeAsync(HttpContext context) { _db = context.RequestServices.GetService(typeof(Models.ApplicationContext)) as Models.ApplicationContext; // Триггер при удалении пользователя из AspNetUsers на установку значения NULL на место FriendId во всех записях в UserToFriends await _db.Database.ExecuteSqlInterpolatedAsync($"CREATE OR ALTER TRIGGER set_null_in_UserToFriends_after_deleting_from_AspNetUsers ON [dbo].[AspNetUsers] AFTER DELETE AS BEGIN UPDATE [dbo].[UserToFriends] SET FriendId = NULL WHERE FriendId = (SELECT Id FROM deleted) END"); // Триггер при удалении пользователя из AspNetUsers на удаление строк из UserToFollowers с FollowerId == Id await _db.Database.ExecuteSqlInterpolatedAsync($"CREATE OR ALTER TRIGGER remove_row_from_UserToFollowers_after_deleting_from_AspNetUsers ON [dbo].[AspNetUsers] AFTER DELETE AS BEGIN DELETE FROM [dbo].[UserToFollowers] WHERE FollowerId = (SELECT Id FROM deleted) END"); // Триггер при удалении пользователя из AspNetUsers на удаление строк из UserToRequests с RequestId == Id await _db.Database.ExecuteSqlInterpolatedAsync($"CREATE OR ALTER TRIGGER remove_row_from_UserToRequests_after_deleting_from_AspNetUsers ON [dbo].[AspNetUsers] AFTER DELETE AS BEGIN DELETE FROM [dbo].[UserToRequests] WHERE RequestId = (SELECT Id FROM deleted) END"); await _next.Invoke(context); }
public SitesController(Models.ApplicationContext context, ILogger <SitesController> logger) { _context = context; _logger = logger; }
public CartController(Models.ApplicationContext context) { db = context; }
public OrderController(Models.ApplicationContext context, ILogger <OrderController> logger) { _context = context; _logger = logger; }
public ProductController(Models.ApplicationContext context, ILogger <ProductController> logger) { _context = context; _logger = logger; }
public CategoryController(Models.ApplicationContext context, ILogger <CategoryController> logger) { _context = context; _logger = logger; }