// GET: Datasets public ActionResult Index() { var discretistationFileHandler = new Discretistation.FileHandler(); var datasetList = datasetRepository.GetAll(); string name = User.Identity.GetUserName(); List <ViewPermissions> vpList = new List <ViewPermissions>(); var viewPermissions = db.ViewPermissions.Where(u => u.UserName == name); foreach (ViewPermissions vp in viewPermissions) { vpList.Add(vp); } foreach (var dataset in datasetList) { foreach (var disc in dataset.Discretizations) { discretizationRepository.Edit(disc); } } discretizationRepository.SaveChanges(); var testStuff = datasetRepository.GetAll().Where(item => item.Owner.Email == User.Identity.Name).ToList(); DatasetIndexViewModel datasetIndexViewModel = new DatasetIndexViewModel() { Datasets = datasetRepository.GetAll(), ViewPermissionsRecords = vpList }; return(View(datasetIndexViewModel)); }
public ActionResult Index() { string currentUserId = null; List <ViewPermissions> vpList = new List <ViewPermissions>(); if (User != null && User.Identity != null) { currentUserId = User.Identity.GetUserId(); } if (currentUserId != null) { ApplicationUser user = db.Users.Find(currentUserId); if (!user.EmailConfirmed) { ViewBag.Confirm = "Dear " + user.FirstName + " " + user.LastName + ", Please confirm your email address and wait for us to confirm your email in order to perform actions in the website. We thank you for your patience."; } string name = user.UserName; var viewPermissions = db.ViewPermissions.Where(u => u.UserName == name); foreach (ViewPermissions vp in viewPermissions) { vpList.Add(vp); } } DatasetIndexViewModel datasetIndexViewModel = new DatasetIndexViewModel() { Datasets = db.Datasets.ToList(), ViewPermissionsRecords = vpList }; return(View(datasetIndexViewModel)); }
public ActionResult OwnedDatasets() { string currentUserId = User.Identity.GetUserId(); DatasetIndexViewModel datasetIndexViewModel = new DatasetIndexViewModel() { Datasets = datasetRepository.GetAll().Where(d => d.Owner != null && d.Owner.Id == currentUserId).ToList() }; return(View(datasetIndexViewModel)); }
public string Download(DatasetIndexViewModel datasetIndexViewModel) { var datasetsRecords = datasetIndexViewModel.DatasetsRecords; var discretizationsRecords = datasetIndexViewModel.DiscretizationsRecords; var karmaLegoRecords = datasetIndexViewModel.KarmaLegoRecords; var discretistationFileHandler = new Discretistation.FileHandler(); Dictionary <int, string> idToParameters = new Dictionary <int, string>(); Dictionary <int, bool> idToRawFlag = new Dictionary <int, bool>(); DatasetService datasetService = new DatasetService(datasetRepository); List <string> allParamsToSend = new List <string>(); if (datasetsRecords != null) { foreach (var datasetRecord in datasetsRecords) { Dataset dataset = datasetRepository.Get(Int32.Parse(datasetRecord)); allParamsToSend.Add(dataset.Path); dataset.NumberOfDownloads += 1; datasetRepository.Edit(dataset); datasetRepository.SaveChanges(); } } if (discretizationsRecords != null) { foreach (var discretizationsRecord in discretizationsRecords) { var discretization = discretizationRepository.Get(Int32.Parse(discretizationsRecord)); var dataset = discretization.Dataset; var datasetPath = dataset.Path; allParamsToSend.Add(discretization.DownloadPath); } } if (karmaLegoRecords != null) { foreach (var karmaLegoRecord in karmaLegoRecords) { var kl = db.KarmaLegos.Find(Int32.Parse(karmaLegoRecord)); var discretization = kl.Discretization; var datasetPath = discretization.Dataset.Path; allParamsToSend.Add(kl.DownloadPath); } } var allParamsToSendString = String.Join(" ", allParamsToSend); return(allParamsToSendString); }