Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SemesterListExists(SemesterList.IDSemester))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (this.NoteFile != null)
            {
                var fileName = GetUniqueName(this.NoteFile.FileName);
                var uploads  = Path.Combine(_environment.WebRootPath, "uploads");
                var filePath = Path.Combine(uploads, fileName);
                this.NoteFile.CopyTo(new FileStream(filePath, FileMode.Create));
                Note.NoteFileURL     = uploads;
                Note.NoteFileCaption = fileName; // Set the file name
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NoteExists(Note.IDNote))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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