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")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.SemesterList.Add(SemesterList); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.SubjectList.Add(SubjectList); await _context.SaveChangesAsync(); Message = "został dodany do listy."; return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Note = await _context.Note.FindAsync(id); if (Note != null) { _context.Note.Remove(Note); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } SemesterList = await _context.SemesterList.FindAsync(id); if (SemesterList != null) { _context.SemesterList.Remove(SemesterList); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } SubjectList = await _context.SubjectList.FindAsync(id); if (SubjectList != null) { _context.SubjectList.Remove(SubjectList); await _context.SaveChangesAsync(); } Message = "został usunięty z listy."; return(RedirectToPage("./Index")); }
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")); }
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.Note.Add(Note); await _context.SaveChangesAsync(); StatusMessage = "Notatka została dodana pomyślnie!"; return(RedirectToPage("./Index")); }