private FilesViewModel GetCourseFiles(FilesViewModel model, Course course, int currentPage) { List <PresentationFiles> presentationFiles = new List <PresentationFiles>(); foreach (Presentation presentation in course.Presentations) { if (repository.PresentationFiles .Any(f => f.PresentationId == presentation.PresentationId)) { presentationFiles.AddRange(repository.PresentationFiles .Where(f => f.PresentationId == presentation.PresentationId)); } } model.Files = presentationFiles.AsQueryable() .Skip((currentPage - 1) * MaxFilesPerCourse) .Take(MaxFilesPerCourse); model.CoursePageInfo = new FilesPerCourseInfo { CurrentPage = currentPage, FilesPerPage = MaxFilesPerCourse, TotalFiles = presentationFiles.Count() }; return(model); }
public async Task <ViewResult> SharedFiles(string id) { ViewData["Id"] = id; ViewData["Title"] = "Files"; AppUser user = userManager.Users.FirstOrDefault(u => u.Id == id); List <FilesViewModel> files = new List <FilesViewModel>(); foreach (Course course in repository.Courses .Where(c => c.CreatedBy.CompanyName == user.CompanyName || c.CreatedBy.CompanyName == "")) { FilesViewModel viewModel = new FilesViewModel { Course = course }; if ((repository.CourseUsers.FirstOrDefault(cu => cu.CourseId == course.CourseId && cu.AppUserId == user.Id) != null) || await userManager.IsInRoleAsync(user, "Admin") || await userManager.IsInRoleAsync(user, "Manager")) { files.Add(GetCourseFiles(viewModel, course, 1)); } } return(View("Files", files.AsQueryable())); }
public DownloadFilePage(FilesViewModel model) { this.model = model; InitializeComponent(); BindingContext = this; Title = model.Title; }
public async Task UploadFilesViaModel(List <FileInputModel> models) { try { foreach (var model in models) { var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot", model.FileToUpload.GetFilename()); using (var stream = new FileStream(path, FileMode.Create)) { await model.FileToUpload.CopyToAsync(stream); } var model1 = new FilesViewModel(); foreach (var item in this.fileProvider.GetDirectoryContents("")) { model1.Files.Add( new FileDetails { Name = item.Name, Path = item.PhysicalPath }); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static async Task SaveFile(IConfiguration config, FilesViewModel model, FileStoreDTO fileStoreDto, ICommonDataService dataService) { var folderForSave = config.GetSection("FileStorePath").Value + DateTime.Now.ToString("ddMMyyyy") + "/"; var filePath = Path.GetFullPath(folderForSave); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } var newName = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".zip"; var tempfolder = Path.GetTempPath(); var fullOrigPath = tempfolder + model.name; string fullZipPath = filePath + newName; var directoryInfo = (new FileInfo(fullOrigPath)).Directory; directoryInfo?.Create(); await File.WriteAllBytesAsync(fullOrigPath, Convert.FromBase64String(model.file)); CreateZip(fullZipPath, fullOrigPath); FileStoreHelper.DeleteFileIfExist(fullOrigPath); fileStoreDto.FileName = newName; fileStoreDto.FilePath = fullZipPath; dataService.Add <FileStore>(fileStoreDto); }
//public FilesViewModel UpdateHistory() //{ // var model = new FilesViewModel(); // //TODO - refresh Historiklistan, annan model // var userId = User.Identity.GetUserId(); // var orgIdForUser = _portalService.HamtaUserOrganisationId(userId); // IEnumerable<FilloggDetaljDTO> historyFileList = _portalService.HamtaHistorikForOrganisation(orgIdForUser); // model.HistorikLista = historyFileList.ToList(); // return model; //} public ActionResult RefreshFilesHistory(FilesViewModel model) { var userId = User.Identity.GetUserId(); var orgIdForUser = _portalService.HamtaUserOrganisationId(userId); var valdaDelregisterInfoList = _portalService.HamtaValdaDelregisterForAnvandare(User.Identity.GetUserId(), orgIdForUser).ToList(); //List<FilloggDetaljDTO> historyFileList = _portalService.HamtaHistorikForOrganisation(orgIdForUser).ToList(); var historyFileList = _portalService.HamtaTop10HistorikForOrganisationAndDelreg(orgIdForUser, valdaDelregisterInfoList).ToList(); //Filtrera historiken utfrån användarens valda register IEnumerable <FilloggDetaljDTO> filteredHistoryFileList = _portalService.FiltreraHistorikForAnvandare(userId, valdaDelregisterInfoList, historyFileList); model.HistorikLista = filteredHistoryFileList.ToList(); //return Json(historyFileList, JsonRequestBehavior.AllowGet); //return Json(new JsonResult() //{ // Data = "Result" //}, JsonRequestBehavior.AllowGet); return(PartialView("_FilesHistory", model)); }
public IActionResult Files() { var descricoes = this._context.ReportarOcorrencia .Where(x => x.ReportarOcorrenciaId > 0) .GroupBy(s => new { district = s.Descricao }) .Select(x => new { count = x.Count(), district = x.Key.district }) .ToList(); var loc = this._context.ReportarOcorrencia .Where(x => x.ReportarOcorrenciaId > 0) .GroupBy(s => new { district = s.Localizacao }) .Select(x => new { count = x.Count(), district = x.Key.district }) .ToList(); var pri = this._context.ReportarOcorrencia .Where(x => x.ReportarOcorrenciaId > 0) .GroupBy(s => new { district = s.Propriedade }) .Select(x => new { count = x.Count(), district = x.Key.district }) .ToList(); int count = 0; var model = new FilesViewModel(); foreach (var item in _fileProvider.GetDirectoryContents("")) { model.Files.Add( new FileDetails { Name = item.Name, Path = item.PhysicalPath, Descricao = count >= descricoes.Count() ? "" : descricoes[count].district, Localizacao = count >= loc.Count() ? "" : loc[count].district, Prioridade = count >= pri.Count() ? "" : pri[count].district }); count++; } return(View(model)); }
public ActionResult Index(string id) { id = id ?? "/"; var instance = new FtpClient(); instance.Host = ftpUrl; instance.Credentials = new System.Net.NetworkCredential(ftpUser, ftpPassword); instance.ValidateCertificate += (c, e) => { e.Accept = true; }; if (id.EndsWith("/")) { var vm = new FilesViewModel { CurrentFolder = id }; vm.Items = instance.GetListing(id, FtpListOption.ForceList).OrderByDescending(x => x.Type).ThenBy(x => x.Name).ToList(); if (id != "/") { vm.Items.Insert(0, new FtpListItem { FullName = GetParent(id), Name = "..", Type = FtpFileSystemObjectType.Directory }); } return(View(vm)); } else { using (Stream istream = instance.OpenRead(id)) { Response.ContentType = "application/octet-stream"; istream.CopyTo(Response.OutputStream); return(new EmptyResult()); } } }
public void GivenAFileSearchesViewModel_WhenIGetACollectionOfFileSearchesViewModels_ThenItIsInitialized() { var model = new FilesViewModel(); List <FileViewModel> gridRuns = model.Files; gridRuns.Should().NotBeNull(); }
public async Task <IActionResult> Create(int id, FilesViewModel fileModel) { if (!ModelState.IsValid) { return(View(fileModel)); } string path = Path.Combine(_env.WebRootPath, "didacticMaterials"); string fileName = Guid.NewGuid().ToString() + fileModel.File.FileName; string resultPath = Path.Combine(path, fileName); using (FileStream fileStream = new FileStream(resultPath, FileMode.Create)) { await fileModel.File.CopyToAsync(fileStream); } DidacticMaterial didacticMaterial = new DidacticMaterial { CourseId = id, Path = fileName, PublishDate = DateTime.Now, Title = fileModel.Title }; await _dbContext.DidacticMaterials.AddAsync(didacticMaterial); await _dbContext.SaveChangesAsync(); return(RedirectToAction("OwnCourses", "Course")); }
public ActionResult Files(int?gid, int?did) { CheckCr(); var uid = User.Identity.GetUserId(); var viewModel = new FilesViewModel(); viewModel.Gp = db.GroupPersons .Include(i => i.Group) .Include(i => i.User); ViewBag.UserId = uid; List <GroupPerson> gpr = viewModel.Gp.Where(u => u.User.Id == uid && u.Status == "Confirmed").ToList(); List <Group> gro = new List <Group>(); for (var i = 0; i < gpr.Count; i++) { gro.Add(gpr[i].Group); } viewModel.Groups = gro; //ask about connection IMPORTANT!!!!!! viewModel.groups //var userProfiles = _dataContext.UserProfile // .Where(t => idList.Contains(t.Id)); if (gid != null) { List <File> fil; fil = db.Files.Where(f => f.Group.GId == gid).ToList(); ViewBag.GroupId = gid; viewModel.File = fil; } return(View(viewModel)); }
public async Task <ComplexResultViewModel> SaveContacts([FromBody] FilesViewModel fileVM) { var userId = (await GetCurrentUserAsync()).Id; var dbElements = await _contactRepository.GetContactsById(userId); var contactsFromUser = _fileFormatService.GetContactsFromFile(fileVM); var successContacts = Mapper.Map <IEnumerable <Contact> >(contactsFromUser.SuccessfullySaved) .ToArray(); for (int i = 0; i < successContacts.Count(); i++) { successContacts[i].UserId = userId; } var successContactsCutVer = successContacts.Select(x => new { x.Name, x.Phone }); var forInsertCutVer = successContactsCutVer.Except( dbElements.Select(x => new { x.Name, x.Phone })); var forUpdateCutVer = successContactsCutVer.Except(forInsertCutVer); var forInsert = successContacts.Where(x => forInsertCutVer.Contains(new { x.Name, x.Phone })) .ToArray(); var forUpdate = successContacts.Where(x => forUpdateCutVer.Contains(new { x.Name, x.Phone })) .ToArray(); await _contactRepository.InsertMany(forInsert); await _contactRepository.Update(forUpdate); return(contactsFromUser); }
public IActionResult Index() { var model = new FilesViewModel(); if (User.IsInRole("Administrator")) { foreach (var item in this.fileProvider.GetDirectoryContents("")) { model.Files.Add( new FileDetails { Name = item.Name, Path = item.PhysicalPath }); } } else { foreach (var item in this.fileProvider.GetDirectoryContents(User.Identity.Name)) { model.Files.Add( new FileDetails { Name = item.Name, Path = item.PhysicalPath }); } } return(View(model)); }
public ActionResult UpdateFile(FilesViewModel _MailViewModel) { if (string.IsNullOrEmpty(_MailViewModel.Path)) { _MailViewModel.IsValid = false; } else { Uri uriResult; bool result = Uri.TryCreate(_MailViewModel.Path, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); if (result) { _MailViewModel.IsValid = true; } else { _MailViewModel.IsValid = false; } } var Data = TelerikMvcWebMail.Common.CallWebApi("api/ApiHome/UpdateFile", RestSharp.Method.POST, _MailViewModel); bool Result = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <bool>(Data); return(Json(Result, JsonRequestBehavior.AllowGet)); }
public ActionResult IngetAttRapportera(FilesViewModel model) { if (ModelState.IsValid) { try { //Hämta orgId, skapa leverans för orgId, spara i db var orgId = _portalService.HamtaUserOrganisationId(User.Identity.GetUserId()); var orgenhet = new Organisationsenhet(); if (!String.IsNullOrEmpty(model.IngetAttRapporteraForSelectedUnitId)) { orgenhet = _portalService.HamtaOrganisationsenhetMedEnhetskod(model.IngetAttRapporteraForSelectedUnitId, orgId); } var id = Convert.ToInt32(model.IngetAttRapporteraForRegisterId); var forvLevId = _portalService.HamtaForvantadleveransIdForRegisterOchPeriod(Convert.ToInt32(model.IngetAttRapporteraForRegisterId), model.IngetAttRapporteraForPeriod); var levId = _portalService.HamtaNyttLeveransId(User.Identity.GetUserId(), User.Identity.GetUserName(), orgId, Convert.ToInt32(model.IngetAttRapporteraForRegisterId), orgenhet.Id, forvLevId, "Inget att rapportera"); } catch (Exception e) { Console.WriteLine(e); ErrorManager.WriteToErrorLog("FileUploadController", "IngetAttRapportera", e.ToString(), e.HResult, User.Identity.Name); var errorModel = new CustomErrorPageModel { Information = "Ett fel inträffade när information om att inget finns att rapportera för aktuell period skulle sparas.", ContactEmail = ConfigurationManager.AppSettings["ContactEmail"], }; return(View("CustomError", errorModel)); } } return(RedirectToAction("Index")); }
public NewFolderPage(FilesViewModel model) { this.model = model; InitializeComponent(); BindingContext = this; Title = model.Title; }
public MainWindow() { InitializeComponent(); FilesViewModel fvm = new FilesViewModel(); DataContext = fvm; }
public ActionResult Search(string file) { var filesViewModel = new FilesViewModel(); var xmlFiles = _xmlFileService.Search(file, this._userService.GetUserManCoIds()); filesViewModel.AddFiles(xmlFiles); return(View(filesViewModel)); }
// Files public ActionResult Files() { var vm = new FilesViewModel { Title = "Files" }; return(View(vm)); }
public async Task <FilesViewModel> GetFiles(int folderId) { FilesViewModel model = new FilesViewModel(); model.FileList = await _fileService.GetFiles(folderId); return(model); }
public object CreateViewModel(System.Windows.DependencyObject sender) { var vm = new FilesViewModel(); vm.ServiceLocator.RegisterService<Mediator>(MediatorFactory.GetCommonMediator()); vm.ServiceLocator.RegisterService<IExplorer>(new Explorer()); vm.Initialize(); return vm; }
public void FileSearchCollection_WhenIAccessTheCollection_ThenItIsTheSameAsTheSetValue() { var files = new List <FileViewModel>(); var model = new FilesViewModel(); model.Files = files; model.Files.Should().BeEquivalentTo(files); }
public object CreateViewModel(System.Windows.DependencyObject sender) { var vm = new FilesViewModel(); vm.ServiceLocator.RegisterService <Mediator>(MediatorFactory.GetCommonMediator()); vm.ServiceLocator.RegisterService <IExplorer>(new Explorer()); vm.Initialize(); return(vm); }
public ActionResult Index() { JsonFiles listOfFiles = _filesHelper.GetFileList(); var model = new FilesViewModel() { Files = listOfFiles.files }; return(View("Index2", model)); }
public ActionResult Show() { var listOfFiles = _filesHelper.GetFileList(); var model = new FilesViewModel { Files = listOfFiles.files }; return(View(model)); }
public ActionResult CourseFiles(int courseId, int currentPage) { Course course = repository.Courses.FirstOrDefault(c => c.CourseId == courseId); FilesViewModel viewModel = new FilesViewModel { Course = course }; return(PartialView("CourseFiles", GetCourseFiles(viewModel, course, currentPage))); }
public ActionResult Show() { JsonFiles ListOfFiles = filesHelper.GetFileList(); var model = new FilesViewModel() { Files = ListOfFiles.files }; return(View(model)); }
public ActionResult Show() { string subFolder = Request.QueryString["subFolder"] != null ? HttpContext.Request.QueryString["subFolder"].ToString() : "user-files"; JsonFiles ListOfFiles = filesHelper.GetFileList(subFolder); var model = new FilesViewModel() { Files = ListOfFiles.files }; return(View(model)); }
public FileBrowser(IFolder folder) { InitializeComponent(); BindingContext = viewModel = new FilesViewModel(folder); //MessagingCenter.Subscribe<NewFolderPage, String>(this, "AddFolder", async (obj, item) => //{ // IFolder f = await folder.CreateFolderAsync(item, CreationCollisionOption.OpenIfExists); // await Navigation.PushAsync(new FileBrowser(f)); //}); }
public async Task <IActionResult> Index() { var fileReferences = await _fileClientService.GetFileReferences(); var viewModel = new FilesViewModel() { Files = fileReferences }; return(View(viewModel)); }
public IActionResult Files() { var model = new FilesViewModel(); foreach (var item in this.fileProvider.GetDirectoryContents("")) { model.Files.Add(new FileDetails { Name = item.Name, Path = item.PhysicalPath }); } return(View(model)); }