public ActionResult ContulMeu(string mail) { ResourcesRepository rr = new ResourcesRepository(); var model = rr.GetUserByMail(mail); return(View(model)); }
public ActionResult CautaLiceu(string searchedHighSchoolName) { var rr = new ResourcesRepository(); var model = rr.GetHighSchoolByName(searchedHighSchoolName); return(View(model)); }
public ActionResult PaginaProfesorului(string mail) { var rr = new ResourcesRepository(); var user = rr.GetUserByMail(mail); return(View(user)); }
public ActionResult VizualizareLectiiMaterie(string mail, string numeMaterie) { var rr = new ResourcesRepository(); var model = rr.GetAllLessons(mail, numeMaterie); return(View(model)); }
public _ResourceMngr(CultureInfo culture) { _culture = culture; _rscLbls = ResourcesRepository.GetResourceLabels(culture); _rscMsgs = ResourcesRepository.GetResourceMessages(culture); }
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")); }
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); } }
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); } }
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. }
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); } }
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); } }
public ActionResult Index() { ResourcesRepository repository = new ResourcesRepository(); var data = repository.GetAll(); return(View(data)); }
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 Aggregator() { UserRepository = new UserRepository(); EntitiesRepository = new EntitiesRepository(); ResourcesRepository = new ResourcesRepository(); IntentionsRepository = new IntentionsRepository(); DifficultyLevelsRepository = new DifficultyLevelsRepository(); }
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)); }
public ActionResult CereriInregistrare() { List <InregistrareProfesorModel> requests; var rr = new ResourcesRepository(); requests = rr.GetAllRegistrationRequests(); return(View(requests)); }
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); }
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")); }
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(); } }
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)); } }
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()); }
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; } } }
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; } } }
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; } } }
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); }
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)); }
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); } }
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); }
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); }
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")); }