Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            var formSecurity    = Request.Form["SecurityText"].ToString();
            var sessionSecurity = HttpContext.Session.GetString("SecurityText");


            if (formSecurity != sessionSecurity)
            {
                ErrorMessage = "(시크릿트 문자를 확인하세요)";
                return(Page());
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var CreateMovie = new Movie();

            if (await TryUpdateModelAsync <Movie>(
                    CreateMovie, "movie",
                    m => m.Title, m => m.ReleaseDate, m => m.Gener, m => m.Price))

            {
                _context.Movies.Add(CreateMovie);
                await _context.SaveChangesAsync();


                await OnPostUploadAsync(CreateMovie.ID);

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

            return(Page());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var courseToUpdate = await _context.Courses.FindAsync(id);


            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (await TryUpdateModelAsync <Course>(courseToUpdate, "course",
                                                   c => c.Credits, c => c.DepartmentID, c => c.Title))
            {
                await _context.SaveChangesAsync();

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

            PopulateDepartmentsDropdownList(_context, courseToUpdate.DepartmentID);
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Instructor instructor = await _context.Instructors
                                    .SingleAsync(i => i.ID == id);

            var departments = await _context.Departments
                              .Where(d => d.InstructorID == id)
                              .ToListAsync();

            departments.ForEach(d => d.InstructorID = null);

            _context.Instructors.Remove(instructor);

            await _context.SaveChangesAsync();

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


            //Instructor = await _context.Instructors.FindAsync(id);

            //if (Instructor != null)
            //{
            //    _context.Instructors.Remove(Instructor);
            //    await _context.SaveChangesAsync();
            //}

            //return RedirectToPage("./Index");
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Student = await _context.Students.AsNoTracking().FirstOrDefaultAsync(s => s.ID == id);


            if (Student == null)
            {
                return(NotFound());
            }

            try
            {
                _context.Students.Remove(Student);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            catch (Exception)
            {
                return(RedirectToPage("./Delete", new { id, saveChangeError = true }));
            }
        }
        public async Task <IActionResult> OnPostAsync(string[] selectedCourses)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var newInstructor = new Instructor();

            if (selectedCourses != null)
            {
                newInstructor.CourseAssignments = new List <CourseAssignment>();

                foreach (var item in selectedCourses)
                {
                    newInstructor.CourseAssignments.Add(new CourseAssignment
                    {
                        CourseID = int.Parse(item)
                    });
                }
            }

            if (await TryUpdateModelAsync <Instructor>(newInstructor, "instructor",
                                                       i => i.FirstMidName, i => i.LastName, i => i.HireDate, i => i.OfficeAssignment))
            {
                _context.Instructors.Add(newInstructor);
                await _context.SaveChangesAsync();

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

            PopulateAssignedCourseData(_context, newInstructor);
            return(Page());
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> OnPostAsync()
        {
            var formSecurity    = Request.Form["SecurityText"].ToString();
            var sessionSecurity = HttpContext.Session.GetString("SecurityText");


            if (formSecurity != sessionSecurity)
            {
                ErrorMessage = "(시크릿트 문자를 확인하세요)";
                return(Page());
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyStudent = new Student();

            if (await TryUpdateModelAsync <Student>(
                    emptyStudent,
                    "student",
                    s => s.FirstMidName, s => s.LastName, s => s.EnrollmentDate))
            {
                _context.Students.Add(emptyStudent);
                await _context.SaveChangesAsync();

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

            return(Page());
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> OnPostAsync(int?id, string[] selectedCourses)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var instructorToUpdate = await _context.Instructors
                                     .Include(i => i.OfficeAssignment)
                                     .Include(i => i.CourseAssignments)
                                     .ThenInclude(i => i.Course)
                                     .FirstOrDefaultAsync(m => m.ID == id);

            if (await TryUpdateModelAsync <Instructor>(
                    instructorToUpdate, "instructor",
                    i => i.FirstMidName, i => i.LastName, i => i.OfficeAssignment, i => i.HireDate))
            {
                if (string.IsNullOrWhiteSpace(instructorToUpdate.OfficeAssignment?.Location))
                {
                    instructorToUpdate.OfficeAssignment = null;
                }
                UpdateInsructorCourse(_context, selectedCourses, instructorToUpdate);

                await _context.SaveChangesAsync();

                return(Redirect("./Index" + Request.Query["Path"].ToString()));
            }
            UpdateInsructorCourse(_context, selectedCourses, instructorToUpdate);
            PopulateAssignedCourseData(_context, instructorToUpdate);
            return(Page());
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            var formSecurity    = Request.Form["SecurityText"].ToString();
            var sessionSecurity = HttpContext.Session.GetString("SecurityText");


            if (formSecurity != sessionSecurity)
            {
                studentFrm = new StudentFrm();
                studentFrm.ErrorMessage = "(시크릿트 문자를 확인하세요)";
                studentFrm.frmType      = FrmType.Modify;

                return(Page());
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var studenntUpdate = await _context.Students.FindAsync(id);

            if (await TryUpdateModelAsync <Student>(
                    studenntUpdate, "student",
                    s => s.FirstMidName, s => s.LastName, s => s.EnrollmentDate))
            {
                await _context.SaveChangesAsync();

                //패스를 이용하여 Return 관련 변수 화인
                return(Redirect("../Index" + System.Web.HttpUtility.UrlDecode(Request.Query["Path"].ToString())));
                //return RedirectToPage("./Index");
            }

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

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DepartmentExists(Department.DepartmentID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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

            Course = await _context.Courses.FindAsync(id);

            if (Course == null)
            {
                return(NotFound());
            }

            try
            {
                _context.Courses.Remove(Course);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            catch (DbUpdateException)
            {
                return(RedirectToPage("./Delete", new { id, errorMessage = true }));
            }
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            var formSecurity    = Request.Form["SecurityText"].ToString();
            var sessionSecurity = HttpContext.Session.GetString("SecurityText");


            if (formSecurity != sessionSecurity)
            {
                ErrorMessage = "(시크릿트 문자를 확인하세요)";
                return(Page());
            }
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var MovieToUpdate = await _context.Movies.FindAsync(id);


            if (await TryUpdateModelAsync <Movie>(
                    MovieToUpdate, "movie",
                    m => m.Title, m => m.ReleaseDate, m => m.Gener, m => m.Price))
            {
                await _context.SaveChangesAsync();

                return(Redirect("./Index" + Request.Query["Path"].ToString()));
            }

            return(Page());
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> OnPostAsync()
        {
            var formSecurity    = Request.Form["SecurityText"].ToString();
            var sessionSecurity = HttpContext.Session.GetString("SecurityText");


            if (formSecurity != sessionSecurity)
            {
                ErrorMessage = "(시크릿트 문자를 확인하세요)";
                return(Page());
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyCourse = new Course();

            if (await TryUpdateModelAsync <Course>(
                    emptyCourse, "course",
                    c => c.CourseID, c => c.Title, c => c.Credits, c => c.DepartmentID))
            {
                _context.Courses.Add(emptyCourse);
                await _context.SaveChangesAsync();

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

            ViewData["Department"] = new SelectList(_context.Departments.OrderBy(d => d.Name),
                                                    "DepartmentID", "name", emptyCourse.DepartmentID);
            return(Page());
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Departments.Add(Department);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> OnPostAsync(object summernote, string aa)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var newBoard = new mBoard();


            //newBoard.Name = "ImsiName";
            //newBoard.WriterID = "ImsiID";

            var bb = summernote;

            if (await TryUpdateModelAsync <mBoard>(
                    newBoard, "mboard", b => b.WriterID, b => b.Name, b => b.Password,
                    b => b.Password, b => b.Title, b => b.Content, b => b.Category, b => b.Encoing))
            {
                newBoard.PosteDate     = DateTime.Now;
                newBoard.PostIp        = HttpContext.Connection.RemoteIpAddress.ToString();
                newBoard.ReadCount     = 0;
                newBoard.ReplySubCount = 0;


                _context.mBoards.Add(newBoard);
                await _context.SaveChangesAsync();

                newBoard.Ref      = newBoard.ID;
                newBoard.Step     = 0;
                newBoard.RefOrder = 0;
                newBoard.DelFlag  = false;

                await _context.SaveChangesAsync();

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

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

            var ParentBoard = _context.mBoards.AsNoTracking().FirstOrDefault(m => m.ID == Id);

            var newBoard = new mBoard();


            //newBoard.Name = "ImsiName";
            //newBoard.WriterID = "ImsiID";



            if (await TryUpdateModelAsync <mBoard>(
                    newBoard, "mboard", b => b.WriterID, b => b.Name, b => b.Password,
                    b => b.Password, b => b.Title, b => b.Content, b => b.Category, b => b.Encoing))
            {
                newBoard.PosteDate     = DateTime.Now;
                newBoard.PostIp        = HttpContext.Connection.RemoteIpAddress.ToString();
                newBoard.ReadCount     = 0;
                newBoard.ReplySubCount = 0;

                newBoard.Ref      = ParentBoard.Ref;
                newBoard.Step     = ParentBoard.Step + 1;
                newBoard.RefOrder = ParentBoard.RefOrder + 1;
                newBoard.DelFlag  = false;

                _context.mBoards.Add(newBoard);

                var mBoardsToUpdate = _context.mBoards.Where(m => m.Ref == ParentBoard.Ref && m.RefOrder >= newBoard.RefOrder);
                await mBoardsToUpdate.ForEachAsync(m => m.RefOrder = m.RefOrder + 1);


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

                ParentBoard.ReplySubCount++;

                await _context.SaveChangesAsync();

                var aa = Request.Query["Path"].ToString();
                //return RedirectToPage("./Index");
                return(Redirect("../mBoards" + Request.Query["Path"].ToString()));
            }

            return(Page());
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            mBoard = await _context.mBoards.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Course = await _context.Courses.AsNoTracking().FirstOrDefaultAsync(m => m.CourseID == id);

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

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Department = await _context.Departments.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Movie = await _context.Movies.FindAsync(id);

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

            return(Redirect("./Index" + Request.Query["Path"].ToString()));
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            mBoard = await _context.mBoards.FirstOrDefaultAsync(m => m.ID == id);

            if (mBoard == null)
            {
                return(NotFound());
            }

            mBoard.ReadCount++;
            await _context.SaveChangesAsync();

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

            var emptyCourse = new Course();

            if (await TryUpdateModelAsync <Course>(emptyCourse, "course",
                                                   c => c.CourseID, c => c.DepartmentID, c => c.Title, c => c.Credits))
            {
                _context.Courses.Add(Course);
                await _context.SaveChangesAsync();

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

            PopulateDepartmentsDropdownList(_context, emptyCourse.DepartmentID);
            return(Page());
        }
Ejemplo n.º 22
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            // 보안문자는 글쓰기에만 사용
            //var formSecurity = Request.Form["SecurityText"].ToString();
            //var sessionSecurity = HttpContext.Session.GetString("SecurityText");

            //if (formSecurity != sessionSecurity)
            //{
            //    ViewData["Department"] = new SelectList(_context.Departments.OrderBy(d => d.Name),
            //    "DepartmentID", "Name");

            //    ErrorMessage = "(시크릿트 문자를 확인하세요)";
            //    return Page();

            //}

            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            var courseToUpdate = await _context.Courses.FindAsync(id);


            if (await TryUpdateModelAsync <Course>(
                    courseToUpdate, "course",
                    c => c.CourseID, c => c.Title, c => c.Credits, c => c.DepartmentID))
            {
                await _context.SaveChangesAsync();

                //패스를 이용하여 Return 관련 변수 화인
                return(Redirect("./Index" + Request.Query["Path"].ToString()));
            }

            ViewData["Department"] = new SelectList(_context.Departments.OrderBy(d => d.Name),
                                                    "DepartmentID", "Name");

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

            var mBoardToUpdate = await _context.mBoards.FindAsync(id);

            if (await TryUpdateModelAsync <mBoard>(
                    mBoardToUpdate, "mboard", b => b.WriterID, b => b.Name, b => b.Password,
                    b => b.Password, b => b.Title, b => b.Content, b => b.Category, b => b.Encoing))
            {
                mBoardToUpdate.ModifyDate = DateTime.Now;
                mBoardToUpdate.PostIp     = HttpContext.Connection.RemoteIpAddress.ToString();

                await _context.SaveChangesAsync();

                //return RedirectToPage("./Index");
                return(Redirect("../mBoards" + Request.Query["Path"].ToString()));
            }

            return(Page());
        }