예제 #1
0
        /// <summary>
        /// Activates the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="versionId">The version identifier.</param>
        /// <returns>ActionResult.</returns>
        public ActionResult Activate(Guid id, Guid?versionId)
        {
            try
            {
                var material = this.entityService.Get <Material>(id, versionId);

                if (material == null)
                {
                    this.TempData["error"] = Locale.UnableToRetrieveMaterial;
                    return(RedirectToAction("Edit", new { id = id, versionId = versionId }));
                }

                var updatedMaterial = entityService.Activate(material);

                this.TempData["success"] = Locale.MaterialActivatedSuccessfully;

                return(RedirectToAction("Edit", new { id = id, versionId = updatedMaterial.VersionKey }));
            }
            catch (Exception e)
            {
                Trace.TraceError($"Unable to activate material: { e }");
            }

            this.TempData["error"] = Locale.UnableToActivateMaterial;

            return(RedirectToAction("Edit", new { id = id, versionId = versionId }));
        }