public void InseramProfesori()
        {
            using (var context = new EducatieIncluzivaDBContext())
            {
                const string parola          = "parola";
                const string nume            = "nume";
                const string prenume         = "prenume";
                const string mail            = "*****@*****.**";
                const string imageUrlForTest =
                    "C:\\Users\\vlad.mirel\\Documents\\Visual Studio 2012\\Projects\\EduIncluziva(1)\\EduIncluziva_01\\EduIncluziva\\Pictures\\Profesori\\Test\\testpic1.jpg";
                for (int i = 0; i < 10; i++)
                {
                    var random = new Random();

                    int    rand = random.Next(0, _numeLicee.Length);
                    string name = _numeLicee[rand];

                    HighSchool highSchool = _resourcesRepository.GetHighSchoolByName(name);

                    var teacher = new Teacher(
                        parola + i.ToString(), nume + i.ToString(),
                        prenume + i.ToString(), mail + i.ToString(),
                        highSchool, imageUrlForTest,
                        "Bio test in care punem si liceul " + highSchool);

                    context.Teachers.Add(teacher);
                }
                context.SaveChanges();
            }
        }
        public void InseramElevi()
        {
            using (var context = new EducatieIncluzivaDBContext())
            {
                string parola  = "parola";
                string nume    = "nume";
                string prenume = "prenume";
                string mail    = "*****@*****.**";

                for (int i = 0; i < 10; i++)
                {
                    Random random = new Random();

                    int    rand = random.Next(0, _numeLicee.Length);
                    string name = _numeLicee[rand];

                    HighSchool highSchool = _resourcesRepository.GetHighSchoolByName(name);

                    Student student = new Student(parola + i.ToString(), nume + i.ToString(),
                                                  prenume + i.ToString(), mail + i.ToString(), highSchool);

                    context.Students.Add(student);
                }
                context.SaveChanges();
            }
        }
示例#3
0
        public ActionResult RegisterElevi(ElevRegisterModel model)
        {
            if (ModelState.IsValid)
            {
                ResourcesRepository rr = new ResourcesRepository();
                HighSchool          hs = rr.GetHighSchoolByName(model.ScoalaDeProvenienta);

                Student elev = new Student(model.Parola, model.Nume, model.Prenume, model.Mail, hs);

                //User user = new User(model.Parola, model.Nume, model.Prenume, model.Mail);

                using (var db = new EducatieIncluzivaDBContext())
                {
                    //db.Useri.Add(user);
                    db.Entry(hs).State = EntityState.Unchanged;
                    db.Students.Add(elev);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

                    FormsAuthentication.SetAuthCookie(model.Mail, false /* createPersistentCookie */);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            // If we got this far, something failed, redisplay form
            return(View());
        }
示例#4
0
        public void TestAddStudent_AddOneStudentTwoTimes()
        {
            HighSchool school  = new HighSchool();
            Student    student = new Student("asd", 10000);

            school.AddStudent(student);
            school.AddStudent(student);
        }
        public void SetProperStartYear_WhenTheObjectIsConstructed()
        {
            var name      = "Thomas Jefferson";
            var startYear = 2018;

            var highSchool = new HighSchool(name, startYear);

            Assert.AreEqual(startYear, highSchool.StartYear);
        }
示例#6
0
        public void TestAddCourse()
        {
            HighSchool school = new HighSchool();
            Course     course = new Course();

            school.AddCourse(course);

            Assert.AreEqual(1, school.Courses.Count);
        }
        public void CreateInstance_When_CorrectParamatersArePassed()
        {
            var name      = "Thomas Jefferson";
            var startYear = 2018;

            var highSchool = new HighSchool(name, startYear);

            Assert.IsNotNull(highSchool);
        }
示例#8
0
        public void TestAddStudent()
        {
            HighSchool school  = new HighSchool();
            Student    student = new Student("asd", 10000);

            school.AddStudent(student);

            Assert.AreEqual(1, school.Students.Count);
        }
示例#9
0
        public async Task <HighSchool> Get(Guid Id)
        {
            if (Id == Guid.Empty)
            {
                return(null);
            }
            HighSchool HighSchool = await UOW.HighSchoolRepository.Get(Id);

            return(HighSchool);
        }
示例#10
0
 public ActionResult CautaUtilizator(UserInfoModel userInfoModel)
 {
     if (ModelState.IsValid)
     {
         ResourcesRepository rr         = new ResourcesRepository();
         HighSchool          highSchool = rr.GetHighSchoolByName("Liceu1");
         rr.UpdateUser(userInfoModel.Parola, userInfoModel.Nume, userInfoModel.Prenume, userInfoModel.Mail, highSchool);
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
示例#11
0
        public void TestRemoveStudent()
        {
            HighSchool school   = new HighSchool();
            Student    student1 = new Student("asd", 10000);
            Student    student2 = new Student("qwe", 10001);

            school.AddStudent(student1);
            school.AddStudent(student2);
            school.RemoveStudent(student1);

            Assert.AreEqual(student2, school.Students[0]);
        }
        public async Task <bool> Update(HighSchool highSchool)
        {
            await tFContext.HighSchool.Where(t => t.Id.Equals(highSchool.Id)).UpdateFromQueryAsync(t => new HighSchoolDAO
            {
                Id         = highSchool.Id,
                Code       = highSchool.Code,
                Name       = highSchool.Name,
                ProvinceId = highSchool.ProvinceId
            });

            return(true);
        }
示例#13
0
 public void InsertInitialHighSchools()
 {
     using (var context = new EducatieIncluzivaDBContext())
     {
         foreach (var numeLiceu in _numeLicee)
         {
             var highSchool = new HighSchool();
             highSchool.Nume         = numeLiceu;
             highSchool.HighSchoolId = Guid.NewGuid();
             context.HighSchools.Add(highSchool);
         }
         context.SaveChanges();
     }
 }
        public async Task <HighSchool> Get(Guid Id)
        {
            HighSchool HighSchool = await tFContext.HighSchool.Where(p => p.Id.Equals(Id)).Select(p => new HighSchool
            {
                Id           = p.Id,
                Code         = p.Code,
                Name         = p.Name,
                ProvinceId   = p.ProvinceId,
                ProvinceCode = p.Province.Code,
                ProvinceName = p.Province.Name
            }).FirstOrDefaultAsync();

            return(HighSchool);
        }
        public async Task <bool> Create(HighSchool highSchool)
        {
            HighSchoolDAO HighSchoolDAO = new HighSchoolDAO
            {
                Id         = highSchool.Id,
                Code       = highSchool.Code,
                Name       = highSchool.Name,
                ProvinceId = highSchool.ProvinceId,
            };

            tFContext.HighSchool.Add(HighSchoolDAO);
            await tFContext.SaveChangesAsync();

            return(true);
        }
示例#16
0
        public async Task <HighSchool> Get(Guid Id)
        {
            HighSchool HighSchool = await tFContext.HighSchool.Where(h => h.Id.Equals(Id)).Select(h => new HighSchool
            {
                Id           = h.Id,
                Code         = h.Code,
                Name         = h.Name,
                ProvinceId   = h.ProvinceId,
                ProvinceCode = h.Province.Code,
                ProvinceName = h.Province.Name,
                Address      = h.Address,
            }).FirstOrDefaultAsync();

            return(HighSchool);
        }
        public void UpdateUser(string parola, string nume, string prenume, string mail,
                               HighSchool scoalaDeProvenienta)
        {
            using (var context = new EducatieIncluzivaDBContext())
            {
                var theUser = this.GetUserByMail(mail);
                theUser.Parola              = parola == null ? theUser.Parola : parola;
                theUser.Nume                = nume == null ? theUser.Nume : nume;
                theUser.Prenume             = prenume == null ? theUser.Prenume : prenume;
                theUser.Mail                = mail == null ? theUser.Mail : mail;
                theUser.ScoalaDeProvenienta = (scoalaDeProvenienta == theUser.ScoalaDeProvenienta) ? theUser.ScoalaDeProvenienta : scoalaDeProvenienta;

                context.Users.Attach(theUser);
                context.Entry(theUser).State = EntityState.Modified;
                context.SaveChanges();
            }
        }
示例#18
0
        public async Task <HighSchoolDTO> GetHighSchool([FromBody] HighSchoolDTO highSchoolDTO)
        {
            if (highSchoolDTO == null)
            {
                highSchoolDTO = new HighSchoolDTO();
            }
            var highSchool = new HighSchool {
                Id = highSchoolDTO.Id
            };

            highSchool = await HighSchoolService.Get(highSchool.Id);

            return(highSchool == null ? null : new HighSchoolDTO
            {
                Id = highSchool.Id,
                Code = highSchool.Code,
                Name = highSchool.Name,
                ProvinceId = highSchool.ProvinceId,
            });
        }
示例#19
0
        public void RefreshHighSchoolsProperty()
        {
            HighSchools.Clear();

            try
            {
                HighSchool item0 = new HighSchool {
                    Id = 0, Name = string.Empty
                };
                HighSchools.Add(item0);
                DbContext.HighSchools.OrderBy(x => x.Name).ToList().ForEach(x => HighSchools.Add(x));
                OnPropertyChanged(nameof(HighSchools));
            }
            catch (EntityException e)
            {
                OnEntityException(e);
            }
            catch (DbEntityValidationException e)
            {
                OnDbEntityValidationException(e);
            }
        }
示例#20
0
        public void RefreshHighSchoolsForSearchProperty()
        {
            HighSchools.Clear();

            try
            {
                HighSchool item0 = new HighSchool {
                    Id = 0, Name = DafaultConstant.DefaultHighSchool
                };
                HighSchoolsForSearch.Add(item0);
                DbContext.HighSchools.OrderBy(x => x.Name).ToList().ForEach(x => HighSchoolsForSearch.Add(x));
                OnPropertyChanged(nameof(HighSchoolsForSearch));
            }
            catch (EntityException e)
            {
                OnEntityException(e);
            }
            catch (DbEntityValidationException e)
            {
                OnDbEntityValidationException(e);
            }
        }
示例#21
0
        public void Initialize(MisglbDbContext context)
        {
            context.Database.EnsureCreated();

            // Look for any applications
            if (context.Applications.Any())
            {
                Console.WriteLine("Applications exists.");
                return; // DB has been seeded
            }

            var applications = new Application[]
            {
                new Application
                {
                    UserId              = "111",
                    AcademicYearStart   = DateTime.Parse("2017-08-08"),
                    AcademicYearEnd     = DateTime.Parse("2018-01-08"),
                    IsSummerApplication = false,
                    ApplicationStatus   = ApplicationStatus.Ongoing,
                    LastName            = "Garcia",
                    FirstName           = "Victor",
                    // No nickname
                    SSN                     = "04-12345",
                    Gender                  = Gender.Male,
                    DOB                     = DateTime.Parse("1989-08-07"),
                    PlaceOfBirth            = "Jaluit",
                    Age                     = 28,
                    HomeAtoll               = "Jaluit",
                    EbeyeKwajResOrLandOwner = false,
                    MartialStatus           = MartialStatus.Single,
                    hasChildren             = false,
                    // No Children
                    ParentMartialStatus         = ParentsStatus.Married,
                    DegreeSought                = "M.A.",
                    CollegeStanding             = CollegeStanding.Senior,
                    FieldOfStudy                = "MIS",
                    DateOfGraduation            = DateTime.Parse("2012-05-01"),
                    DateFinAidNeeded            = DateTime.Parse("2017-11-01"),
                    SavingsDividendsInterests   = 0,
                    EmploymentIncome            = 0,
                    SpouseIncome                = 0,
                    GovernmentSalary            = 0,
                    Compensation                = 0,
                    OthersResources             = 0,
                    ReceivedFinAidBefore        = true,
                    ReceivedFinAidBeforeDate    = DateTime.Parse("2012-09-01"),
                    EducationExpenseTermType    = ExpenseType.One_Term,
                    ExpenseTermSemesterSpecific = Semester.Spring,
                    // no expensetermsemesterspecific
                    TuitionType        = TuitionType.NA,
                    Tuition            = 100.00m,
                    Supplies           = 100.00m,
                    RoomAndBoardMonths = 4,
                    RoomAndBoard       = 100.00m,
                    HealthInsurance    = 100.00m,
                    Miscellaneous      = 100.00m,
                    Transportation     = 100.00m,
                    Airfare            = 100.00m,
                    // total expenses automatically summed and set
                    FinancialExpenseTermType = ExpenseType.Per_Academic_Year,
                    // no financialtermsemesterspecific
                    PellGrant          = 0,
                    CollegeScholarship = 0,
                    OtherScholarship   = 0,
                    ParentalSupport    = 0,
                    // personalassets automatically set from assets
                    OthersFinancial = 0,
                    // totalfinancial auto summed and set
                    // totalfinassistanceneeded auto summed and set
                    HasFather   = true,
                    HasMother   = true,
                    HasGuardian = false
                },
                new Application
                {
                    UserId              = "123",
                    AcademicYearStart   = DateTime.Parse("2017-08-08"),
                    AcademicYearEnd     = DateTime.Parse("2018-01-08"),
                    IsSummerApplication = false,
                    ApplicationStatus   = ApplicationStatus.New,
                    LastName            = "Billy",
                    FirstName           = "Bob",
                    // No nickname
                    SSN                     = "04-11111",
                    Gender                  = Gender.Male,
                    DOB                     = DateTime.Parse("1989-09-07"),
                    PlaceOfBirth            = "Majuro",
                    Age                     = 21,
                    HomeAtoll               = "Majuro",
                    EbeyeKwajResOrLandOwner = false,
                    MartialStatus           = MartialStatus.Single,
                    hasChildren             = false,
                    // No Children
                    ParentMartialStatus       = ParentsStatus.Married,
                    DegreeSought              = "B.A.",
                    CollegeStanding           = CollegeStanding.Freshman,
                    DateFinAidNeeded          = DateTime.Parse("2017-11-01"),
                    SavingsDividendsInterests = 300.00M,
                    EmploymentIncome          = 0,
                    SpouseIncome              = 0,
                    GovernmentSalary          = 0,
                    Compensation              = 0,
                    OthersResources           = 0,
                    ReceivedFinAidBefore      = false,
                    // receivedFinAidBeforeDate not needed
                    EducationExpenseTermType = ExpenseType.Per_Academic_Year,
                    // No ExpenseTermSemesterSpecific
                    TuitionType        = TuitionType.NA,
                    Tuition            = 100.00m,
                    Supplies           = 200.00M,
                    RoomAndBoardMonths = 4,
                    RoomAndBoard       = 200.00M,
                    HealthInsurance    = 200.00M,
                    Miscellaneous      = 200.00M,
                    Transportation     = 200.00M,
                    Airfare            = 100.00M,
                    // Total expenses automatically summed and set
                    FinancialExpenseTermType = ExpenseType.Per_Academic_Year,
                    // No FinancialTermSemesterSpecific
                    PellGrant          = 0,
                    CollegeScholarship = 0,
                    OtherScholarship   = 0,
                    ParentalSupport    = 500.00M,
                    // PersonalAssets automatically set from assets
                    OthersFinancial = 0,
                    // TotalFinancial auto summed and set
                    // totalFinAssistanceNeeded auto summed and set
                    HasFather   = true,
                    HasMother   = true,
                    HasGuardian = false,
                }
            };

            foreach (Application a in applications)
            {
                context.Applications.Add(a);
            }
            context.SaveChanges();
            List <Application> apps1 = new List <Application>();

            apps1.Add(applications[0]);

            List <Application> apps2 = new List <Application>();

            apps2.Add(applications[1]);

            // Current Contacts
            var currentContacts = new CurrentContact[]
            {
                new CurrentContact
                {
                    Application = apps1,
                    Country     = "RMI",
                    State_Atoll = "Majuro",
                    Address     = "PO Box 123",
                    Zip         = "96960",
                    Phone       = "6924562596",
                    Email       = "*****@*****.**"
                },
                new CurrentContact
                {
                    Application = apps2,
                    Country     = "RMI",
                    State_Atoll = "Majuro",
                    Address     = "PO Box 111",
                    Zip         = "96960",
                    Phone       = "6924562596",
                    Email       = "*****@*****.**"
                }
            };

            foreach (CurrentContact c in currentContacts)
            {
                context.Contacts.Add(c);
            }
            context.SaveChanges();

            // Permanent Contacts
            var permanentContacts = new PermanentContact[]
            {
                new PermanentContact
                {
                    Application = apps1,
                    Country     = "RMI",
                    State_Atoll = "Majuro",
                    Address     = "PO Box 123",
                    Zip         = "96960",
                    Phone       = "6924562596"
                },
                new PermanentContact
                {
                    Application = apps2,
                    Country     = "RMI",
                    State_Atoll = "Majuro",
                    Address     = "PO Box 111",
                    Zip         = "96960",
                    Phone       = "6924562596"
                }
            };

            foreach (PermanentContact p in permanentContacts)
            {
                context.Contacts.Add(p);
            }
            context.SaveChanges();

            // Emergency Contacts
            var emergencyContacts = new EmergencyContact[]
            {
                new EmergencyContact
                {
                    Application  = applications[0],
                    LastName     = "Garcia",
                    FirstName    = "Leilani",
                    Phone        = "6924560277",
                    Email        = "*****@*****.**",
                    Relationship = "Mother"
                },
                new EmergencyContact
                {
                    Application  = applications[1],
                    LastName     = "Jane",
                    FirstName    = "Sue",
                    Phone        = "6924560277",
                    Email        = "*****@*****.**",
                    Relationship = "Mother"
                }
            };

            foreach (EmergencyContact e in emergencyContacts)
            {
                context.EmergencyContact.Add(e);
            }
            context.SaveChanges();

            // Fathers
            var fathers = new Father[]
            {
                new Father
                {
                    Application = apps1,
                    FirstName   = "Victor",
                    LastName    = "Garcia Sr.",
                    Alive       = true,
                    Age         = 60,
                    // no Employer
                    AnnualIncome = 0
                },
                new Father
                {
                    Application = apps2,
                    FirstName   = "Ken",
                    LastName    = "Joe",
                    Alive       = true,
                    Age         = 60,
                    // no Employer
                    AnnualIncome = 0
                }
            };

            foreach (Father f in fathers)
            {
                context.Parents.Add(f);
            }
            context.SaveChanges();

            // Mothers
            var mothers = new Mother[]
            {
                new Mother
                {
                    Application  = apps1,
                    FirstName    = "Lelani",
                    LastName     = "Garcia",
                    Alive        = true,
                    Age          = 50,
                    Employer     = "Polaris",
                    AnnualIncome = 3000.00M
                },
                new Mother
                {
                    Application  = apps2,
                    FirstName    = "Sara",
                    LastName     = "Joe",
                    Alive        = true,
                    Age          = 50,
                    Employer     = "KK",
                    AnnualIncome = 3000.00M
                }
            };

            foreach (Mother m in mothers)
            {
                context.Parents.Add(m);
            }
            context.SaveChanges();


            //Current Colleges
            var currentColleges = new CurrentCollege[]
            {
                new CurrentCollege
                {
                    Name        = "UH - Manoa",
                    Country     = "US",
                    State_Atoll = "HI",
                    Address     = "123 St.",
                    Zip         = "96822",
                    Application = apps1
                },
                new CurrentCollege
                {
                    Name        = "Chaminade",
                    Country     = "US",
                    State_Atoll = "HI",
                    Address     = "123 St.",
                    Zip         = "96822",
                    Application = apps2
                }
            };

            foreach (CurrentCollege c in currentColleges)
            {
                context.Schools.Add(c);
            }
            context.SaveChanges();

            //Prior Collegs
            var priorColleges = new PriorCollege[]
            {
                new PriorCollege
                {
                    Application    = apps1,
                    Name           = "UMN Duluth",
                    Country        = "US",
                    State_Atoll    = "MN",
                    Address        = "123 St.",
                    Zip            = "56751",
                    DegreeObtained = "B.A.A"
                }
            };

            foreach (PriorCollege p in priorColleges)
            {
                context.Schools.Add(p);
            }
            context.SaveChanges();

            // High Schools
            var highSchools = new HighSchool[]
            {
                new HighSchool
                {
                    Application         = apps1,
                    Name                = "Roseau High School",
                    Country             = "US",
                    State_Atoll         = "MN",
                    Address             = "123 St.",
                    Zip                 = "56751",
                    HighSchoolStartDate = DateTime.Parse("2012-09-01"),
                    HighSchoolEndDate   = DateTime.Parse("2013-05-01"),
                    HighSchoolGradDate  = DateTime.Parse("2013-05-01")
                },
                new HighSchool
                {
                    Application         = apps2,
                    Name                = "Baptist HS",
                    Country             = "RMI",
                    State_Atoll         = "Majuro",
                    Address             = "123 St.",
                    Zip                 = "96960",
                    HighSchoolStartDate = DateTime.Parse("2012-09-01"),
                    HighSchoolEndDate   = DateTime.Parse("2013-05-01"),
                    HighSchoolGradDate  = DateTime.Parse("2013-05-01")
                }
            };

            foreach (HighSchool h in highSchools)
            {
                context.Schools.Add(h);
            }
            context.SaveChanges();
        }
示例#22
0
 public Student(string parola, string nume, string prenume, string mail, HighSchool scoalaDeProvenienta) :
     base(parola, nume, prenume, mail, scoalaDeProvenienta)
 {
     Role = ElevRole;
 }
示例#23
0
        public void TestHighSchool_CoursesEqualsZero()
        {
            HighSchool school = new HighSchool();

            Assert.AreEqual(0, school.Courses.Count);
        }
示例#24
0
        public void TestHighSchool_StudentEqualsZero()
        {
            HighSchool school = new HighSchool();

            Assert.AreEqual(0, school.Students.Count);
        }