コード例 #1
0
        public ActionResult ContulMeu(string mail)
        {
            ResourcesRepository rr = new ResourcesRepository();
            var model = rr.GetUserByMail(mail);

            return(View(model));
        }
コード例 #2
0
        public ActionResult CautaLiceu(string searchedHighSchoolName)
        {
            var rr    = new ResourcesRepository();
            var model = rr.GetHighSchoolByName(searchedHighSchoolName);

            return(View(model));
        }
コード例 #3
0
        public ActionResult PaginaProfesorului(string mail)
        {
            var rr   = new ResourcesRepository();
            var user = rr.GetUserByMail(mail);

            return(View(user));
        }
コード例 #4
0
        public ActionResult VizualizareLectiiMaterie(string mail, string numeMaterie)
        {
            var rr    = new ResourcesRepository();
            var model = rr.GetAllLessons(mail, numeMaterie);

            return(View(model));
        }
コード例 #5
0
            public _ResourceMngr(CultureInfo culture)
            {
                _culture = culture;

                _rscLbls = ResourcesRepository.GetResourceLabels(culture);
                _rscMsgs = ResourcesRepository.GetResourceMessages(culture);
            }
コード例 #6
0
        public ActionResult AdaugaPoza(HttpPostedFileBase file, string mail)
        {
            // Verify that the user selected a file
            if (file != null && file.ContentLength > 0)
            {
                // extract only the fielname
                var fileName = Path.GetFileName(file.FileName);
                //store the file in a new created folder
                //the new created folder bears the name of the logged in user = teacher
                var directoryPath = Server.MapPath("~/Content/Pictures/Profesori/" + mail);
                Directory.CreateDirectory(directoryPath);
                var path = Path.Combine(Server.MapPath("~/Content/Pictures/Profesori/" + mail), fileName);
                file.SaveAs(path);


                //update the user so that he now stores the picture
                string imageUrl = "~/Content/Pictures/Profesori/" + mail + "/" + fileName;

                var rr = new ResourcesRepository();
                rr.UpdateTeacher(mail, imageUrl);
                var user = rr.GetUserByMail(mail);
            }
            // redirect back to the index action to show the form once again
            return(RedirectToAction("Index", "Home"));
        }
コード例 #7
0
        public async void DeleteAsync_ChangesQuantity()
        {
            //Arrange
            var contextOptions = InMemoryUtils.ProduceFreshDbContextOptions();
            var oldModel       = ResourceUtils.TestSet.First();
            int oldQuantity;

            using (var context = new ApplicationDbContext(contextOptions))
            {
                context.Resources.Add(oldModel);
                context.SaveChanges();
                oldQuantity = context.Resources.Count();
            }

            //Act
            using (var context = new ApplicationDbContext(contextOptions))
            {
                IBasicRepositoryAsync <Resource, int> repo = new ResourcesRepository(context);
                await repo.DeleteAsync(oldModel.Id);
            }

            //Assert
            using (var context = new ApplicationDbContext(contextOptions))
            {
                Assert.Equal(1, oldQuantity);
                Assert.Empty(context.Resources);
            }
        }
コード例 #8
0
        public async void ExistsAsync_ReturnsCorrectBool(int id, bool expected)
        {
            //Arrange
            var options = InMemoryUtils.ProduceFreshDbContextOptions();

            using (var context = new ApplicationDbContext(options))
            {
                context.Resources.AddRange(ResourceUtils.TestSet);

                context.SaveChanges();
            }

            var model = ResourceUtils.TestSet.Any(r => r.Id == id) ? ResourceUtils.TestSet.Single(r => r.Id == id) : new Resource()
            {
                Id = 999
            };

            //Act
            using (var context = new ApplicationDbContext(options))
            {
                ITrackEntityRepository <Resource, int, ApplicationUser, string> repo = new ResourcesRepository(context);
                var resultKeyed = await repo.ExistsAsync(id);

                var resultModeled = await repo.ExistsAsync(model);

                //Assert
                Assert.IsAssignableFrom <bool>(resultKeyed);
                Assert.Equal(expected, resultKeyed);
                Assert.IsAssignableFrom <bool>(resultModeled);
                Assert.Equal(expected, resultModeled);
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: mvladm14/educatieIncluziva
        static void Main(string[] args)
        {
            Console.WriteLine("Populating with highschools");

            var inserareLicee = new InserareLicee();

            inserareLicee.InsertInitialHighSchools();

            Console.WriteLine("Finished with high schools");


            Console.WriteLine("Adaugam elevi");
            var inserareElevi = new InserareElevi();

            inserareElevi.InseramElevi();
            Console.Write("Am terminat de adaugat elevi");


            var inserareAdministrator = new InserareAdministrator();

            inserareAdministrator.InsertAdministrator();

            var inserareProfesori = new InserareProfesori();

            inserareProfesori.InseramProfesori();
            Console.Write("Am terminat de adaugat profesori");

            var rr = new ResourcesRepository();
            var h  = rr.GetHighSchoolById(new Guid("80bc4591-cc75-4b1a-8162-1808ad8ff8f7"));

            Console.ReadLine();
            //rr.
        }
コード例 #10
0
        public async void UpdateAsync_ChangesFields()
        {
            //Arrange
            var contextOptions = InMemoryUtils.ProduceFreshDbContextOptions();
            var oldModel       = ResourceUtils.TestSet.First();

            using (var context = new ApplicationDbContext(contextOptions))
            {
                context.Resources.Add(oldModel);
                context.SaveChanges();
            }
            var newModel = ResourceUtils.TestSet.Last();

            //Act
            using (var context = new ApplicationDbContext(contextOptions))
            {
                IBasicRepositoryAsync <Resource, int> repo = new ResourcesRepository(context);
                newModel.Id = oldModel.Id;
                await repo.UpdateAsync(newModel);
            }

            //Assert
            using (var context = new ApplicationDbContext(contextOptions))
            {
                Assert.Equal(newModel.Title, context.Resources.First().Title);
                Assert.NotEqual(oldModel.Title, context.Resources.First().Title);
            }
        }
コード例 #11
0
        public async void UpdateSelectiveAsync_ChangesFieldSubsetOnly()
        {
            //Arrange
            var contextOptions = InMemoryUtils.ProduceFreshDbContextOptions();
            var oldModel       = ResourceUtils.TestSet.First();

            using (var context = new ApplicationDbContext(contextOptions))
            {
                context.Resources.Add(oldModel);
                context.SaveChanges();
            }
            var newModel = ResourceUtils.TestSet.Last();

            //Act
            using (var context = new ApplicationDbContext(contextOptions))
            {
                ITrackEntityRepository <Resource, int, ApplicationUser, string> repo = new ResourcesRepository(context);
                newModel.Id = oldModel.Id;
                await repo.UpdateSelectiveAsync <ResourceTestUpdateSubset>(newModel);
            }

            //Assert
            using (var context = new ApplicationDbContext(contextOptions))
            {
                Assert.NotEqual(oldModel.Title, context.Resources.First().Title);
                Assert.Equal(newModel.Title, context.Resources.First().Title);
                Assert.NotEqual(newModel.Description, context.Resources.First().Description);
            }
        }
コード例 #12
0
        public ActionResult Index()
        {
            ResourcesRepository repository = new ResourcesRepository();
            var data = repository.GetAll();

            return(View(data));
        }
コード例 #13
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());
        }
コード例 #14
0
 public Aggregator()
 {
     UserRepository             = new UserRepository();
     EntitiesRepository         = new EntitiesRepository();
     ResourcesRepository        = new ResourcesRepository();
     IntentionsRepository       = new IntentionsRepository();
     DifficultyLevelsRepository = new DifficultyLevelsRepository();
 }
コード例 #15
0
        public ActionResult PaginaElevului(string mail)
        {
            var rr           = new ResourcesRepository();
            var user         = rr.GetUserByMail(mail);
            var highschoolId = user.ScoalaDeProvenientaId;
            var highschool   = rr.GetHighSchoolById(highschoolId);

            return(View(highschool));
        }
コード例 #16
0
        public ActionResult CereriInregistrare()
        {
            List <InregistrareProfesorModel> requests;
            var rr = new ResourcesRepository();

            requests = rr.GetAllRegistrationRequests();

            return(View(requests));
        }
コード例 #17
0
        public ActionResult ViewLesson(string mail, FormCollection c)
        {
            var    rr    = new ResourcesRepository();
            var    model = rr.GetProfesoriByMail(mail);
            string link  = "http://www.google.com";

            return(Redirect(link));
            //return View("../../Views/AddLesson/AddLesson", model);
        }
コード例 #18
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"));
 }
コード例 #19
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();
     }
 }
コード例 #20
0
        public ActionResult SubmitToLesson(string materie, string mail)
        {
            var rr = new ResourcesRepository();

            var model = rr.GetUserByMail(mail);

            if (materie != null)
            {
                ViewData["materie"] = materie;

                return(View("../../Views/AddLesson/AddLesson", model));
            }
            else
            {
                return(View("../../Views/Cont/ContulMeu", model));
            }
        }
コード例 #21
0
 public ActionResult CautaUtilizator(string mail)
 {
     if (ModelState.IsValid)
     {
         ResourcesRepository rr = new ResourcesRepository();
         User          user     = rr.GetUserByMail(mail);
         UserInfoModel newUim   = new UserInfoModel();
         newUim.Nume    = user.Nume;
         newUim.Prenume = user.Prenume;
         newUim.Mail    = user.Mail;
         newUim.Parola  = user.Parola;
         //TODO change the schoolName
         newUim.ScoalaDeProvenienta = "Liceu1";
         return(View(newUim));
     }
     return(View());
 }
コード例 #22
0
        public void EditResource(ResourceEntity resource)
        {
            ResourcesRepository resRepo = new ResourcesRepository();

            using (var uow = UnitOfWork.CreateUoW())
            {
                try
                {
                    resRepo.Update(EntitiesMapper.ToDbModel(resource), uow);
                    uow.ApplyChanges();
                }
                catch (Exception ex)
                {
                    DbLog.LogError("Error editing resource " + resource, ex);
                    throw ex;
                }
            }
        }
コード例 #23
0
        public void DeleteResource(ResourceEntity resource)
        {
            ResourcesRepository resRepo = new ResourcesRepository();

            using (var uow = UnitOfWork.CreateUoW())
            {
                try
                {
                    resRepo.Delete(resource.Id, uow);
                    uow.ApplyChanges();
                }
                catch (Exception ex)
                {
                    DbLog.LogError("Error deleting resource " + resource.Id, ex);
                    throw ex;
                }
            }
        }
コード例 #24
0
        public void InsertResource(ResourceEntity res)
        {
            ResourcesRepository resRepo = new ResourcesRepository();

            using (var uow = UnitOfWork.CreateUoW())
            {
                try
                {
                    resRepo.Create(EntitiesMapper.ToDbModel(res), uow);
                    uow.ApplyChanges();
                }
                catch (Exception ex)
                {
                    uow.Rollback();
                    DbLog.LogError("Error inserting resource " + res, ex);
                    throw ex;
                }
            }
        }
コード例 #25
0
        public List <ResourceEntity> GetResourcesByPartialUsername(string partUsername)
        {
            List <ResourceEntity> result  = new List <ResourceEntity>();
            ResourcesRepository   resRepo = new ResourcesRepository();

            using (var uow = UnitOfWork.CreateUoW())
            {
                try
                {
                    var resList = resRepo.GetResourcesByPartialUsername(partUsername, uow);
                    result = resList.Select(x => EntitiesMapper.ToEntity(x)).ToList();
                }
                catch (Exception ex)
                {
                    DbLog.LogError("Error retrieving resources " + partUsername, ex);
                    throw ex;
                }
            }
            return(result);
        }
コード例 #26
0
        public ActionResult DeleteLesson(string mail, string materie, string name)
        {
            ViewBag.stergere    = null;
            ViewData["materie"] = materie;
            var rr    = new ResourcesRepository();
            var model = rr.GetProfesoriByMail(mail);

            if (rr.EraseLesson(name, mail, materie) == 1)
            {
                ViewBag.eraseData = "Lectia a fost stearsa cu succes";
                ViewBag.stergere  = 1;
            }
            else
            {
                ViewBag.eraseData = "Lectia cu numele " + name + " nu a putut fi stearsa. Verificati cu atentie numele lectiei";
                ViewBag.stergere  = 0;
            }

            return(View("../../Views/AddLesson/AddLesson", model));
        }
コード例 #27
0
        public async void SaveAsync_ChangesQuantity_OnAdd()
        {
            //Arrange
            var contextOptions = InMemoryUtils.ProduceFreshDbContextOptions();

            //Act
            using (var context = new ApplicationDbContext(contextOptions))
            {
                context.Resources.Add(ResourceUtils.TestSet.First());

                IBasicRepositoryAsync <Resource, int> repo = new ResourcesRepository(context);
                await repo.SaveAsync();
            }

            //Assert
            using (var context = new ApplicationDbContext(contextOptions))
            {
                Assert.NotEmpty(context.Resources);
            }
        }
コード例 #28
0
        public List <ResourceEntity> GetAllResources()
        {
            List <ResourceEntity> result  = new List <ResourceEntity>();
            ResourcesRepository   resRepo = new ResourcesRepository();

            using (var uow = UnitOfWork.CreateUoW())
            {
                try
                {
                    var resList = resRepo.GetAllResources(uow);
                    result = resList.Select(x => EntitiesMapper.ToEntity(x)).ToList();
                }
                catch (Exception ex)
                {
                    DbLog.LogError("Error retrieving all resources", ex);
                    throw ex;
                }
            }
            return(result);
        }
コード例 #29
0
        public ResourceEntity GetResourceById(int id)
        {
            ResourceEntity      result  = null;
            ResourcesRepository resRepo = new ResourcesRepository();

            using (var uow = UnitOfWork.CreateUoW())
            {
                try
                {
                    var res = resRepo.GetResourceByID(id, uow);
                    result = res != null?EntitiesMapper.ToEntity(res) : null;
                }
                catch (Exception ex)
                {
                    DbLog.LogError("Error retrieving resource " + id, ex);
                    throw ex;
                }
            }
            return(result);
        }
コード例 #30
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"));
        }