예제 #1
0
        public async Task <IActionResult> Create(App appli)
        {
            try
            {
                SAMLPortalContext context = new SAMLPortalContext();
                if (ModelState.IsValid)
                {
                    if (appli.MetadataURL != null)
                    {
                    }
                    context.Add(appli);
                    await context.SaveChangesAsync();

                    return(RedirectToAction("Index", "App"));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            return(View(appli));
        }
예제 #2
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            SAMLPortalContext context = new SAMLPortalContext();
            var app = await context.App.FindAsync(id);

            if (app == null)
            {
                return(Redirect("/"));
            }

            try
            {
                context.App.Remove(app);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.)
                return(RedirectToAction(nameof(Delete), new { id = id, saveChangesError = true }));
            }
        }
예제 #3
0
        public async Task <IActionResult> EditPost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            SAMLPortalContext context = new SAMLPortalContext();
            var appToUpdate           = await context.App.FirstOrDefaultAsync(s => s.Id == id);

            if (await TryUpdateModelAsync <App>(
                    appToUpdate,
                    "",
                    s => s.Name,
                    s => s.Description,
                    s => s.Role,
                    s => s.Enabled,
                    s => s.MetadataURL,
                    s => s.Issuer,
                    s => s.SingleSignOnDestination,
                    s => s.SingleLogoutResponseDestination))
            {
                try
                {
                    await context.SaveChangesAsync();

                    return(Redirect("/"));
                }
                catch (DbUpdateException /* ex */)
                {
                    //Log the error (uncomment ex variable name and write a log.)
                    ModelState.AddModelError("", "Unable to save changes. " +
                                             "Try again, and if the problem persists, " +
                                             "see your system administrator.");
                }
            }
            return(View("Edit", appToUpdate));
        }