Ejemplo n.º 1
0
        public MessageBuilder Desync([Protect(UserScope.Owner)] Route route)
        {
            var db        = new RepoContext();
            var localizer = Context.GetLocalizer();
            var routeS    = route.ToString();

            db.Remove(route);
            db.SaveChanges();
            return(new MessageBuilder()
                   .Set(MessageFlags.Code)
                   .AddText(localizer["RouteDestroyed"])
                   .AddText(routeS));
        }
Ejemplo n.º 2
0
        public OutMessage Destroy([Protect(UserScope.Owner)] Chat chat = null)
        {
            var localizer = Context.GetLocalizer();
            var db        = new RepoContext();

            chat ??= Context.GetChat();
            if (chat == null)
            {
                return(OutMessage.FromCode(localizer["ChatNotFound"]));
            }
            var routes = chat.Routes.Select(x => x.Route).ToList();

            db.Remove(chat);
            db.SaveChanges();
            routes.ForEach(x => x.DeleteIfNotUsed());
            return(OutMessage.FromCode(localizer["ChatDestroyed"]));
        }
Ejemplo n.º 3
0
        public async Task DeleteHostTests()
        {
            var e = new WatchEntity
            {
                WatchId             = Guid.NewGuid(),
                Emails              = Guid.NewGuid().ToString(),
                Host                = Guid.NewGuid().ToString(),
                PingIntervalSeconds = 1000
            };

            var result = await RepoContext.AddAsync(e);

            await RepoContext.SaveChangesAsync();

            Assert.AreEqual(e.WatchId, result.Entity.WatchId);

            await RepoContext.Remove(e.WatchId);

            var e2 = await RepoContext.GetItem(e.WatchId);

            Assert.IsNull(e2);
        }