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();
            }
        }
Exemple #2
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());
        }
        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();
            }
        }
Exemple #4
0
        public ActionResult CautaLiceu(string searchedHighSchoolName)
        {
            var rr    = new ResourcesRepository();
            var model = rr.GetHighSchoolByName(searchedHighSchoolName);

            return(View(model));
        }
Exemple #5
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"));
 }
Exemple #6
0
 public void InsertAdministrator()
 {
     using (var context = new EducatieIncluzivaDBContext())
     {
         var resourcesRepository = new ResourcesRepository();
         var highSchool          = resourcesRepository.GetHighSchoolByName(SchoolName);
         var administrator       =
             new Administrator(Parola, Nume, Prenume, Mail, highSchool);
         context.Administrators.Add(administrator);
         context.SaveChanges();
     }
 }
Exemple #7
0
        public ActionResult Approve(Guid id)
        {
            var rr = new ResourcesRepository();

            var request = rr.GetRequestById(id);

            var highschool = rr.GetHighSchoolByName(request.ScoalaDeProveninenta);

            var teacher = new Teacher(request.Parola, request.Nume, request.Prenume,
                                      request.Mail, highschool);

            using (var context = new EducatieIncluzivaDBContext())
            {
                var entry = context.RegistrationRequests.Find(id);
                context.RegistrationRequests.Remove(entry);
                context.Teachers.Add(teacher);
                context.SaveChanges();
            }
            return(RedirectToAction("CereriInregistrare"));
        }