/// <summary>
        /// Upon getting the user's information about software entry, adds that to the database.
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync()
        {
            // Whether the model state is valid or not.
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            WebRequest  webRequest = WebRequest.Create(Software.DownloadURL);
            WebResponse webResponse;

            try {
                webResponse = webRequest.GetResponse();
            } catch (System.Exception) {
                return(RedirectToPage("/Error"));
            }

            // Adds the software to ModelContext.
            _context.Software.Add(Software);

            // Waits till changes are saved.
            await _context.SaveChangesAsync();

            // Returns to the Software index page.
            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.ClippedSoftware.Add(ClippedSoftware);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Beispiel #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ClippedSoftware = await _context.ClippedSoftware.FindAsync(id);

            if (ClippedSoftware != null)
            {
                _context.ClippedSoftware.Remove(ClippedSoftware);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #4
0
        /// <summary>
        /// Called when the user deletes the software entry.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            // If the id is null, return not found result.
            if (id == null)
            {
                return(NotFound());
            }

            // Wait till the id is found in the database.
            Software = await _context.Software.FindAsync(id);

            // If the software is not null, delete it and save the changes.
            if (Software != null)
            {
                _context.Software.Remove(Software);
                await _context.SaveChangesAsync();
            }

            // Returns to the Software index page.
            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            // Checks the ensure the model state is valid, if not returns the page and doesn't process anything.
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            // Gets the modified state of the software.
            _context.Attach(Software).State = EntityState.Modified;

            WebRequest  webRequest = WebRequest.Create(Software.DownloadURL);
            WebResponse webResponse;

            try {
                webResponse = webRequest.GetResponse();
            } catch (System.Exception) {
                return(RedirectToPage("/Error"));
            }

            // Saves the changes if the software still exists.
            try {
                await _context.SaveChangesAsync();
            } catch (DbUpdateConcurrencyException) {
                if (!SoftwareExists(Software.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            // Redirects the user to software index page.
            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(ClippedSoftware).State = EntityState.Modified;

            try {
                await _context.SaveChangesAsync();
            } catch (DbUpdateConcurrencyException) {
                if (!ClippedSoftwareExists(ClippedSoftware.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }