Beispiel #1
0
 public ActionResult DeleteExperiment(DeleteExperimentViewModel model)
 {
     ApplicationUserManager manager = Request.GetOwinContext().GetUserManager<ApplicationUserManager>();
     ExperimentAdministrator user = _experimentAdminService.GetExperimentAdministrator(
         manager.FindByName(User.Identity.Name).ExperimentAdministratorId);
     int userId = manager.FindByName(User.Identity.Name).ExperimentAdministratorId;
     Experiment experiment = _experimentService.GetExperimentByName(model.ExperimentName, userId);
     if (experiment.ExperimentAdministrator == user) // Confirm the user owns the experiment
     {
         // Get the experiment ID
         int experimentId = experiment.Id;
         _experimentService.DeleteExperiment(experimentId, userId);
         _experimentService.SaveChanges();
     }
     else
     {
         ModelState.AddModelError("", "ERROR: You do not own that experiment.");
         return View(model);
     }
     return Redirect("/Experiment/DeleteExperimentConfirmation");
 }
Beispiel #2
0
        /// <summary>
        /// Deletes an experiment from the database
        /// </summary>
        /// <param name="experimentName">Name of the experiment to delete</param>
        /// <returns></returns>
        public ActionResult DeleteExperiment(string experimentName)
        {
            DeleteExperimentViewModel model = new DeleteExperimentViewModel();
            model.ExperimentName = experimentName;

            return View(model);
        }