Exemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync(
            string userId,
            int webSitesMenuId,
            int profileId,
            string profileName,
            string webSitesMenuDescription,
            int webSiteId,
            string returnUrl)
        {
            if (string.IsNullOrEmpty(webSitesMenuId.ToString()) ||
                string.IsNullOrEmpty(profileId.ToString()) ||
                string.IsNullOrEmpty(profileName) ||
                string.IsNullOrEmpty(webSitesMenuDescription) ||
                string.IsNullOrEmpty(webSiteId.ToString()) ||
                string.IsNullOrEmpty(returnUrl))
            {
                return(NotFound());
            }

            WebSitesModel = await _context.WebSites.FindAsync(webSiteId);

            if (WebSitesModel == null)
            {
                return(RedirectToPage("/WebSites/WebSitesIndex",
                                      new { userId, profileId, profileName, webSitesMenuId, webSitesMenuDescription, returnUrl, deletedWebSite = "true" }));
            }

            _context.WebSites.Remove(WebSitesModel);
            await _context.SaveChangesAsync();

            return(RedirectToPage("/WebSites/WebSitesIndex",
                                  new { userId, profileId, profileName, webSitesMenuId, webSitesMenuDescription, returnUrl }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> WebSitesEdit(
            [Bind("Id,Description,WebSiteURL,WebSitesMenuId")]
            int?id,
            int?profileId,
            int webSiteMenuId,
            string webSiteMenuDescription,
            WebSitesModel webSitesModel)
        {
            if (String.IsNullOrEmpty(id.ToString()) ||
                String.IsNullOrEmpty(profileId.ToString()) ||
                String.IsNullOrEmpty(webSiteMenuId.ToString()) ||
                String.IsNullOrEmpty(webSiteMenuDescription))
            {
                return(NotFound());
            }

            if (webSitesModel == null ||
                id != webSitesModel.Id)
            {
                return(RedirectToAction(nameof(WebSitesController.WebSitesIndex), new { webSiteMenuId, profileId, webSiteMenuDescription }));
            }

            if (ModelState.IsValid)
            {
                _context.Update(webSitesModel);
                await _context.SaveChangesAsync();
            }
            return(RedirectToAction(nameof(WebSitesController.WebSitesIndex), new { webSiteMenuId, profileId, webSiteMenuDescription }));
        }
Exemplo n.º 3
0
        // POST: WebSitesModels/Delete/5
        //[HttpPost ]
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> WebSitesDelete(
            int id,
            int?profileId,
            int?webSiteMenuId,
            string webSiteMenuDescription,
            WebSitesModel webSitesModel)
        {
            if (String.IsNullOrEmpty(id.ToString()) ||
                String.IsNullOrEmpty(profileId.ToString()) ||
                String.IsNullOrEmpty(webSiteMenuId.ToString()) ||
                String.IsNullOrEmpty(webSiteMenuDescription))
            {
                return(NotFound());
            }

            webSitesModel = await _context.WebSites.SingleOrDefaultAsync(m => m.Id == id);

            if (webSitesModel == null)
            {
                return(RedirectToAction(nameof(WebSitesController.WebSitesIndex), new { webSiteMenuId, profileId, webSiteMenuDescription }));
            }

            _context.WebSites.Remove(webSitesModel);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(WebSitesController.WebSitesIndex), new { webSiteMenuId, profileId, webSiteMenuDescription }));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> OnGetAsync(
            string userId,
            int webSitesMenuId,
            int profileId,
            string profileName,
            string webSitesMenuDescription,
            int webSiteId,
            string returnUrl)
        {
            if (string.IsNullOrEmpty(userId) ||
                string.IsNullOrEmpty(profileId.ToString()) ||
                string.IsNullOrEmpty(profileName) ||
                string.IsNullOrEmpty(webSitesMenuId.ToString()) ||
                string.IsNullOrEmpty(webSitesMenuDescription) ||
                string.IsNullOrEmpty(webSiteId.ToString()) ||
                string.IsNullOrEmpty(returnUrl))
            {
                return(NotFound());
            }

            WebSitesModel = await _context.WebSites
                            .SingleOrDefaultAsync(m => m.Id == webSiteId);

            if (WebSitesModel == null)
            {
                return(RedirectToPage("/WebSites/WebSitesIndex",
                                      new { userId, profileId, profileName, webSitesMenuId, webSitesMenuDescription, returnUrl, deletedWebSite = "true" }));
            }

            TempData["UserId"]                  = userId;
            TempData["ProfileId"]               = profileId;
            TempData["ProfileName"]             = profileName;
            TempData["WebSitesMenuId"]          = webSitesMenuId;
            TempData["WebSitesMenuDescription"] = webSitesMenuDescription;
            TempData["ReturnUrl"]               = returnUrl;

            if (WebSitesModel.WebSiteURL.Length > 35)
            {
                TempData["ShortWebSiteURL"] = WebSitesModel.WebSiteURL.Substring(0, 35) + " ...";
            }
            else
            {
                TempData["ShortWebSiteURL"] = WebSitesModel.WebSiteURL;
            }

            return(Page());
        }
Exemplo n.º 5
0
        WebSitesAddNew([Bind("Id,Description,WebSiteURL,WebSiteMenuId")]
                       int?profileId,
                       int webSiteMenuId,
                       string webSiteMenuDescription,
                       WebSitesModel webSitesModel)
        {
            if (String.IsNullOrEmpty(profileId.ToString()) ||
                String.IsNullOrEmpty(webSiteMenuId.ToString()) ||
                String.IsNullOrEmpty(webSiteMenuDescription))
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                webSitesModel.WebSitesMenuId = webSiteMenuId;
                _context.Add(webSitesModel);
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction(nameof(WebSitesController.WebSitesIndex), new { webSiteMenuId, profileId, webSiteMenuDescription }));
        }