示例#1
0
        // 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(Scholarship).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ScholarshipExists(Scholarship.ScholarshipID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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


            if (studentLoad == null)
            {
                Submission.File = "no file";
            }
            else
            {
                var file = Path.Combine(_env.WebRootPath, "subup", studentLoad.FileName);
                Submission.File = (studentLoad.FileName);


                using (var fileStream = new FileStream(file, FileMode.Create))
                {
                    await studentLoad.CopyToAsync(fileStream);
                }
            }

            Submission.Status = "Pending";

            _context.Submissions.Add(Submission);
            await _context.SaveChangesAsync();

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

            if (Upload == null)
            {
                Scholarship.UploadPath = "no file";
            }
            else
            {
                var file = Path.Combine(_env.WebRootPath, "uploads", Upload.FileName);
                Scholarship.UploadPath = (Upload.FileName);


                using (var fileStream = new FileStream(file, FileMode.Create))
                {
                    await Upload.CopyToAsync(fileStream);
                }
            }

            _context.Scholarships.Add(Scholarship);
            await _context.SaveChangesAsync();


            return(RedirectToPage("./Index"));
        }
示例#4
0
        // 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.Users.Add(User);
            await _context.SaveChangesAsync();

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

            Scholarship = await _context.Scholarships.FindAsync(id);

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

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

            Submission = await _context.Submissions.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
示例#7
0
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            User = await _context.Users.FindAsync(id);

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

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