BExIS.Web.Shell.Areas.Sam.Controllers.DatasetController.Delete C# (CSharp) Method

Delete() public method

Deletes a dataset, which means the dataset is marked as deleted, but is not physically removed from the database.
When a dataset is deleted, it is consodered as non-exisiting, but for the sake or provenance, citation, history, etc, it is not removed froom the database. The function to recover a deleted dataset, will not be provided.
public Delete ( long id ) : System.Web.Mvc.ActionResult
id long the identifier of the dataset to be purged.
return System.Web.Mvc.ActionResult
        public ActionResult Delete(long id)
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Delete", this.Session.GetTenant());
            try
            {
                DatasetManager dm = new DatasetManager();
                if (dm.DeleteDataset(id, this.ControllerContext.HttpContext.User.Identity.Name, true))
                {
                    // during the delete permissions are not removed, to allow purging the dataset later on.
                    // it is a safe operation, because deleted datasets are not returned by the DLM anyway.
                    // Javad and Sven decided on 22.11.2016.
                    //try
                    //{
                    //    PermissionManager pm = new PermissionManager();
                    //    pm.DeleteDataPermissionsByEntity(1, id);
                    //}
                    //catch
                    //{
                    //    ViewData.ModelState.AddModelError("", string.Format("Dataset {0} was deleted, but its permissions were not altered. You need to remove them manually from the data permission management.", id));
                    //}
                    try
                    {
                        ISearchProvider provider = IoCFactory.Container.ResolveForSession<ISearchProvider>() as ISearchProvider;
                        provider?.UpdateSingleDatasetIndex(id, IndexingAction.DELETE);
                    }
                    catch
                    {
                        ViewData.ModelState.AddModelError("", string.Format("Dataset {0} was deleted, but it is still indexed for searching. You need to reindex the search via the managemnet console.", id));
                    }
                }
                else
                {
                    ViewData.ModelState.AddModelError("", string.Format("Dataset {0} could not be deleted. Details: Internal system error!", id));
                }
            }
            catch (Exception ex)
            {
                ViewData.ModelState.AddModelError("", string.Format("Dataset {0} could not be deleted. Details: {1}", id, ex.Message));
            }
            return View();
            //return RedirectToAction("List");
        }