Ejemplo n.º 1
0
        public async Task <IActionResult> Deactivate(Guid id)
        {
            var app = await _ctx.FindApplicationAsync(id);

            if (app != null)
            {
                return(View(new ActivationViewModel {
                    Id = id, Name = app.Name, IsActive = false
                }));
            }

            return(NotFound());
        }
Ejemplo n.º 2
0
        public async Task SaveChangesAsync(EmailServiceContext ctx)
        {
            var app = await ctx.FindApplicationAsync(ApplicationId);

            foreach (var transport in Transports)
            {
                var existing = await ctx.Transports
                               .Where(t => t.Id == transport.TransportId)
                               .SelectMany(t => t.Applications)
                               .FirstOrDefaultAsync(a => a.ApplicationId == ApplicationId);

                if (existing != null)
                {
                    if (transport.Remove)
                    {
                        app.Transports.Remove(existing);
                        ctx.Remove(existing);
                    }
                    else
                    {
                        existing.Priority = transport.Priority;
                    }
                }
            }

            await ctx.SaveChangesAsync();
        }
Ejemplo n.º 3
0
        public async Task SaveChangesAsync(EmailServiceContext ctx)
        {
            var app = await ctx.FindApplicationAsync(Id);

            if (app != null)
            {
                app.IsActive = IsActive;
                await ctx.SaveChangesAsync();
            }
        }
        public async Task SaveChangesAsync(EmailServiceContext ctx)
        {
            var existing = await ctx.FindApplicationAsync(Id);

            if (existing != null)
            {
                existing.Name          = Name;
                existing.Description   = Description;
                existing.SenderAddress = SenderAddress;
                existing.SenderName    = SenderName;
                await ctx.SaveChangesAsync();
            }
        }
Ejemplo n.º 5
0
        public async Task SaveChangesAsync(EmailServiceContext ctx)
        {
            var app = await ctx.FindApplicationAsync(ApplicationId);

            if (app != null)
            {
                app.Transports.Add(new ApplicationTransport
                {
                    TransportId = TransportId.GetValueOrDefault(),
                    Priority    = Priority
                });

                await ctx.SaveChangesAsync();
            }
        }
        public async Task <IActionResult> Get()
        {
            var applicationId = User.GetApplicationId();

            var app = await _context.FindApplicationAsync(applicationId);

            if (app == null)
            {
                throw new InvalidOperationException("Cannot find the authorised application - this is weird");
            }

            return(Ok(new ApplicationInfoResponse
            {
                ApplicationId = app.Id,
                Name = app.Name,
                Description = app.Description
            }));
        }
        public async Task SaveChangesAsync(EmailServiceContext ctx, ICryptoServices crypto)
        {
            var app = await ctx.FindApplicationAsync(Id);

            if (app != null)
            {
                if (IsPrimary)
                {
                    app.PrimaryApiKey = crypto.GeneratePrivateKey();
                }
                else if (IsSecondary)
                {
                    app.SecondaryApiKey = crypto.GeneratePrivateKey();
                }

                await ctx.SaveChangesAsync();
            }
        }
        public static async Task <EditApplicationViewModel> LoadAsync(EmailServiceContext ctx, Guid id)
        {
            var application = await ctx.FindApplicationAsync(id);

            if (application != null)
            {
                return(new EditApplicationViewModel
                {
                    Id = application.Id,
                    Name = application.Name,
                    Description = application.Description,
                    SenderAddress = application.SenderAddress,
                    SenderName = application.SenderName
                });
            }

            return(null);
        }