public ActionResult Create([Bind(Include = "ID,FirstName,LastName,CourseID,EnrollmentDate,PassFail")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "CourseName", student.CourseID);
            return(View(student));
        }
예제 #2
0
        public void Save()
        {
            try
            {
                Teacher teacher = new Teacher()
                {
                    FirstName = teacherView.FirstName,
                    LastName  = teacherView.LastName,
                    BirthDate = teacherView.Birthday,
                };

                database.Teachers.Add(teacher);
                database.SaveChanges();

                DataToGrig();
            }
            catch
            {
                MessageBox.Show("Failed");
            }
        }
        public void Delete(int courseID)
        {
            using (var db = new AcademyContext())
            {
                var courseDeleteQuery = db.Courses.Include(course => course.Bookings);


                SelectedCourse = db.Courses.Find(courseID);
                db.Remove(SelectedCourse);
                db.SaveChanges();
            }
        }
        private CouncilProperty AddPropertyInformationForTaxPayer(int accountRef, string address = null, string postcode = null)
        {
            var occupationDetails = TestHelper.CreateDatabaseOccupationEntityForCouncilProperty(accountRef);

            AcademyContext.Occupations.Add(occupationDetails);
            AcademyContext.SaveChanges();

            var propertyEntity = TestHelper.CreateDatabasePropertyForTaxPayer(occupationDetails.PropertyRef, address, postcode);

            AcademyContext.CouncilProperties.Add(propertyEntity);
            AcademyContext.SaveChanges();
            return(propertyEntity);
        }
        public void Create(string cName, double cPrice)
        {
            var newCourse = new Course()
            {
                CourseName = cName, CoursePrice = cPrice
            };

            using (var db = new AcademyContext())
            {
                db.Courses.Add(newCourse);
                db.SaveChanges();
            }
        }
예제 #6
0
        public void Create(string firstName, string lastName, string emailAddress)
        {
            var newStudent = new Student()
            {
                FirstName = firstName, LastName = lastName, Email = emailAddress
            };

            using (var db = new AcademyContext())
            {
                db.Students.Add(newStudent);
                db.SaveChanges();
                SelectedStudent = db.Students.Find(newStudent.StudentID);
            }
        }
예제 #7
0
        public void TearDown()
        {
            _bookingManager = new BookingManager();
            using (var db = new AcademyContext())
            {
                var selectedBooking =
                    from b in db.Bookings
                    where b.BookingID == 1
                    select b;

                //db.Students.RemoveRange(selectedStudent);
                db.SaveChanges();
            }
        }
        public void TearDown()
        {
            _studentManager = new StudentManager();
            using (var db = new AcademyContext())
            {
                var selectedStudent =
                    from s in db.Students
                    where s.FirstName == "Baray"
                    select s;

                db.Students.RemoveRange(selectedStudent);
                db.SaveChanges();
            }
        }
        public void Create(int studentID, int courseID, string selectedDate)
        {
            var newBooking = new Booking()
            {
                StudentID = studentID, CourseID = courseID, BookingDate = selectedDate, BookingStatus = "Active"
            };

            using (var db = new AcademyContext())
            {
                db.Bookings.Add(newBooking);
                db.SaveChanges();
                SelectedBooking = db.Bookings.Find(newBooking.BookingID);
            }
        }
        public void GetAllResidentsWildcardSearchWithNameQueryParametersetersReturnsMatchingResidentOnlyOnce()
        {
            var databaseEntity = AddPersonRecordToDatabase(firstname: "ciasom", lastname: "Tessellate");

            var address = TestHelper.CreateDatabaseAddressForPersonId(databaseEntity.ClaimId, databaseEntity.HouseId);

            AcademyContext.Addresses.Add(address);
            AcademyContext.SaveChanges();

            var listOfPersons = _classUnderTest.GetAllClaimants(cursor: _defaultCursor, limit: 20, firstname: "ciaso", lastname: "essellat");
            var firstPersonId = listOfPersons.First().ClaimId;

            listOfPersons.Count.Should().Be(1);
            firstPersonId.Should().Be(databaseEntity.ClaimId);
        }
        private Person AddPersonRecordToDatabase(string firstname = null, string lastname = null, int?id        = null,
                                                 bool withClaim   = true, int?memberId    = null, int?personRef = null, int?houseId = null)
        {
            var databaseEntity = TestHelper.CreateDatabaseClaimantEntity(firstname, lastname, id, memberId, personRef, houseId);

            AcademyContext.Persons.Add(databaseEntity);
            AcademyContext.SaveChanges();
            if (withClaim)
            {
                AcademyContext.Claims.Add(new Claim {
                    ClaimId = databaseEntity.ClaimId
                });
                AcademyContext.SaveChanges();
            }
            return(databaseEntity);
        }
        private void AddContactInformationForTaxPayer(int accountRef, List <string> emails = null, List <string> phoneNumbers = null)
        {
            if (emails != null)
            {
                foreach (string email in emails)
                {
                    var emailDetails = TestHelper.CreateDatabaseEmailAddressForTaxPayer(accountRef, email);
                    AcademyContext.Emails.Add(emailDetails);
                    AcademyContext.SaveChanges();
                }
            }

            var phoneDetails = TestHelper.CreateDatabasePhoneNumbersForTaxPayer(accountRef, phoneNumbers);

            AcademyContext.PhoneNumbers.Add(phoneDetails);
            AcademyContext.SaveChanges();
        }
        public void GetAllResidentsWithPostCodeQueryParameterseterReturnsMatchingResident()
        {
            var databaseEntity  = AddPersonRecordToDatabase();
            var databaseEntity1 = AddPersonRecordToDatabase();

            var address = TestHelper.CreateDatabaseAddressForPersonId(databaseEntity.ClaimId, databaseEntity.HouseId, "E8 1DY");

            AcademyContext.Addresses.Add(address);
            AcademyContext.SaveChanges();

            var address1 = TestHelper.CreateDatabaseAddressForPersonId(databaseEntity1.ClaimId, databaseEntity.HouseId, "E8 5TG");

            AcademyContext.Addresses.Add(address1);
            AcademyContext.SaveChanges();

            var listOfPersons = _classUnderTest.GetAllClaimants(cursor: _defaultCursor, limit: 20, postcode: "E8 1DY");

            listOfPersons.Count.Should().Be(1);
            listOfPersons
            .First(p => p.ClaimId == databaseEntity.ClaimId)
            .ClaimantAddress
            .Should().BeEquivalentTo(address.ToDomain());
        }
예제 #14
0
        public void Save()
        {
            try
            {
                database.Students.Add(
                    new Student()
                {
                    FirstName = studentView.FirstName,
                    LastName  = studentView.LastName,
                    BirthDate = studentView.Birthday,
                    IdGroup   = (int)studentView.CmbBoxGroupsViewSelectedValue,
                }
                    );

                database.SaveChanges();
                DataToGrig();
            }
            catch
            {
                MessageBox.Show("Произошла ошибка");
            }
        }
 public void Remove(CourseCategory courseCategory)
 {
     _context.CourseCategories.Remove(courseCategory);
     _context.SaveChanges();
 }
 public void Add(CourseCategory courseCategory)
 {
     _context.CourseCategories.Add(courseCategory);
     _context.SaveChanges();
 }
예제 #17
0
 public void remove(CourseCategory entity)
 {
     _context.CourseCategories.Remove(entity);
     _context.SaveChanges();
 }