Пример #1
0
        public async Task <ActionResult <Applicant> > PostApplicant(Applicant item)
        {
            _context.Applicants.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetApplicant), new { id = item.ID }, item));
        }
        //removes applicant from database when confirm delete button is pressed
        public async Task <IActionResult> OnPostAsync()
        {
            _db.Applicants.Remove(applicant);
            await _db.SaveChangesAsync();

            return(RedirectToPage("Deleted"));
        }
Пример #3
0
        //delete object and return to VIEW page
        public async Task <IActionResult> OnPostAsync()
        {
            if (Student != null)
            {
                var student = await _db.Student.FindAsync(Student.ID);

                _db.Student.Remove(student);
                await _db.SaveChangesAsync();
            }
            return(RedirectToPage("View"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            var child = await _db.Creche.FindAsync(Creche.Ppsn);

            if (child != null)
            {
                _db.Creche.Remove(child);
                await _db.SaveChangesAsync();
            }

            return(RedirectToPage("ListStudents1"));
        }
Пример #5
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                _db.Creche.Add(Creche);
                await _db.SaveChangesAsync();

                return(RedirectToPage("ListStudents1"));
            }
            else
            {
                return(Page());
            }
        }
Пример #6
0
        //if all validation is passed, including atleast one day checked,
        //update applicant and redirect to thank-you page, otherwise return this page
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid && CheckIfADayTicked(applicant))
            {
                _db.Applicants.Update(applicant);
                await _db.SaveChangesAsync();

                return(RedirectToPage("ThankYou", new { id = applicant.ID }));
            }

            else
            {
                return(Page());
            }
        }
Пример #7
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid && Student.MethodDaysOfWeek() && Student.MethodCheckDateStart() && Student.MethodCheckDateBirth())
            {
                _db.Students.Add(Student);
                await _db.SaveChangesAsync();

                //return RedirectToPage("ValueDetails", Student);

                //Feedback from project
                return(RedirectToPage("ValueDetails", new { id = Student.ID }));
            }
            else
            {
                return(Page());
            }
        }
Пример #8
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid && Student.MethodDaysOfWeek() && Student.MethodCheckDateStart() && Student.MethodCheckDateBirth())
            {
                S00190492_Creche.Model.Student Student2 = await _db.Students.FindAsync(Student.ID);

                Student2.ID                  = Student.ID;
                Student2.ChildFirstName      = Student.ChildFirstName;
                Student2.Address             = Student.Address;
                Student2.ChildLastName       = Student.ChildLastName;
                Student2.City                = Student.City;
                Student2.DateOfBirth         = Student.DateOfBirth;
                Student2.Email               = Student.Email;
                Student2.SecondEmail         = Student.SecondEmail;
                Student2.StartingDate        = Student.StartingDate;
                Student2.PPS                 = Student.PPS;
                Student2.Gender              = Student.Gender;
                Student2.ParentFirstName     = Student.ParentFirstName;
                Student2.ParentLastName      = Student.ParentLastName;
                Student2.RelationshipToChild = Student.RelationshipToChild;
                Student2.ZipCode             = Student.ZipCode;
                Student2.MobileNumber        = Student.MobileNumber;
                Student2.SecondContactNumber = Student.SecondContactNumber;
                Student2.Hours               = Student.Hours;
                Student2.DaysOfWeek          = Student.DaysOfWeek;
                Student2.TotalDue            = Student.TotalDue;
                Student2.DiscountValue       = Student.DiscountValue;

                // _db.Students.Update(Student2);
                //Student2 = Student;
                await _db.SaveChangesAsync();

                //return RedirectToPage("ValueDetails", Student);

                //Feedback from project
                return(RedirectToPage("ListStudents"));
            }
            else
            {
                return(Page());
            }
        }
Пример #9
0
        public async Task <IActionResult> OnPostAsync()
        {
            //loading the values for days selected into student object and counting how many days
            var dayNumber = 0;

            ValidDays = false;
            for (int i = 0; i < 5; i++)
            {
                if (DaysSelected[i])
                {
                    ValidDays     = true;
                    Student.Days += " " + Days[i];
                    dayNumber++;
                }
            }

            //loading the values for gender into student object
            var gender = Request.Form["Student.Gender"];

            if (gender == "Male")
            {
                Student.Gender = "Male";
            }
            else
            {
                Student.Gender = "Female";
            }

            //loading the values for relationshop into student object
            string relationship = Request.Form["Student.Relationship"];

            if (relationship == "Father")
            {
                Student.Relationship = "Father";
            }
            if (relationship == "Mother")
            {
                Student.Relationship = "Mother";
            }
            if (relationship == "Other")
            {
                Student.Relationship = "Other";
            }

            //loading the values for part time/full time and calculating price
            Student.Hours = Request.Form["Student.Hours"];
            double price = 0;

            if (Student.Hours == "Part Time")
            {
                price = 20 * dayNumber;
            }
            else
            if (Student.Hours == "Full Time")
            {
                price = 35 * dayNumber;
            }

            //check for valid days, at least one day has to be selected
            if (!ValidDays)
            {
                Error = true;
                return(Page());
            }

            //applying the discount if 4 or 5 days attendance
            if (dayNumber > 3)
            {
                price = price - (price * 10 / 100);
            }
            Student.Cost = price;

            //sending price through session variable
            HttpContext.Session.SetDouble("Price", price);

            if (ModelState.IsValid)
            {
                //saving changes to data base and redirect to Result page
                _db.Student.Add(Student);
                await _db.SaveChangesAsync();

                return(RedirectToPage("/Result"));
            }
            else
            {
                //return to current page if did not pass client side validation
                Error = true;
                return(Page());
            }
        }
Пример #10
0
        public async Task <IActionResult> OnPostAsync()
        {
            //loading the values for days selected into student object and counting how many days
            var dayNumber = 0;

            ValidDays = false;
            for (int i = 0; i < 5; i++)
            {
                if (DaysSelected[i])
                {
                    ValidDays     = true;
                    Student.Days += " " + Days[i];
                    dayNumber++;
                }
            }

            //loading the values for gender into student object
            var gender = Request.Form["Student.Gender"];

            if (gender == "Male")
            {
                Student.Gender = "Male";
            }
            else
            {
                Student.Gender = "Female";
            }

            //loading the values for relationshop into student object
            string relationship = Request.Form["Student.Relationship"];

            if (relationship == "Father")
            {
                Student.Relationship = "Father";
            }
            if (relationship == "Mother")
            {
                Student.Relationship = "Mother";
            }
            if (relationship == "Other")
            {
                Student.Relationship = "Other";
            }

            //loading the values for part time/full time and calculating price
            Student.Hours = Request.Form["Student.Hours"];
            double price = 0;

            if (Student.Hours == "Part Time")
            {
                price = 20 * dayNumber;
            }
            else
            if (Student.Hours == "Full Time")
            {
                price = 35 * dayNumber;
            }

            //check for valid days, at least one day has to be selected
            if (!ValidDays)
            {
                Error = true;
                return(Page());
            }

            //applying the discount if 4 or 5 days attendance
            if (dayNumber > 3)
            {
                price = price - (price * 10 / 100);
            }
            Student.Cost = price;

            //sending price through session variable
            HttpContext.Session.SetDouble("Price", price);

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

            _db.Attach(Student).State = EntityState.Modified;

            try
            {
                await _db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw new Exception($"Student {Student.ID} not found!");
            }

            return(RedirectToPage("Update"));
        }