// 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 async Task <ActionResult> Edit(int?id) { string currentUserId = User.Identity.GetUserId(); if (currentUserId == null) { return(RedirectToAction("Register", "Account")); } ApplicationUser user = db.Users.Find(currentUserId); if (currentUserId != null && !user.EmailConfirmed) { return(RedirectToAction("Index", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Dataset dataset = datasetRepository.Get((int)id); if (dataset == null) { return(HttpNotFound()); } FileTransferrer fileTransferrer = new FileTransferrer(); foreach (var disc in dataset.Discretizations) { string discPath = discretizationService.getPath(datasetService.getPath(dataset.DatasetID), disc.DiscretizationID); discPath += "/KL.txt"; if (System.IO.File.Exists(Server.MapPath(discPath))) { disc.ParametersIsReady = "Ready"; } else { disc.ParametersIsReady = "In Progress"; } discretizationRepository.Edit(disc); } datasetRepository.SaveChanges(); return(View(new DiscretizationExistingViewModel() { DatasetID = (int)id, Discretizations = dataset.Discretizations, Dataset = dataset })); }