protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            switch (this.ParameterSetName)
            {
            case RemoveContentParameterSet:
                foreach (Guid id in Id)
                {
                    ExecuteAction(string.Format("{0}: {1}", Entity, Id), delegate
                    {
                        _repository.Delete(Entity, id);
                    });
                }
                break;

            case RemoveContentByInputObjectParameterSet:
                foreach (Entity input in InputObject)
                {
                    ExecuteAction(string.Format("{0}: {1}", input.LogicalName, input.Id), delegate
                    {
                        _repository.Delete(input.LogicalName, input.Id);
                    });
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Content content = ContentRepository.GetSingle(id);

            try
            {
                LabelLineRepository.DeleteLabelLinesByItem(id, ContentType);
                ContentRepository.Delete(content);
                ContentRepository.Save();
                ClearCache(content.StoreId);


                if (IsSuperAdmin)
                {
                    return(RedirectToAction("Index", new { storeId = content.StoreId, categoryId = content.CategoryId }));
                }
                else
                {
                    return(RedirectToAction("Index", new { categoryId = content.CategoryId }));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Unable to delete it:" + ex.StackTrace, content);
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }


            return(View(content));
        }
Ejemplo n.º 3
0
 internal void deleteDebate(string id)
 {
     _contentRepository.Delete(int.Parse(id));
     _roundStateRepository.Delete(int.Parse(id));
     _categoryDebateRepository.Delete(int.Parse(id));
     _userDebateRepository.Delete(int.Parse(id));
     _debateRepository.Delete(int.Parse(id));
 }
Ejemplo n.º 4
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            ExecuteAction(string.Format("{0}: {1}", "webresource", Id), delegate
            {
                _repository.Delete("webresource", Id);
            });
        }
 private void UnregisterComponents(string logicalName, IEnumerable <Guid> ids)
 {
     foreach (var id in ids)
     {
         ExecuteAction(string.Format("{0}: {1}", logicalName, id), "Unregister", delegate
         {
             _repository.Delete(logicalName, id);
         });
     }
 }
Ejemplo n.º 6
0
        public ActionResult Delete(Content content)
        {
            contentRepository.Delete(content);
            if (UnitOfWork.Save() != 1)
            {
                return(Content("{success:false}"));
            }

            return(Content("{success:true}"));
        }
        /// <summary>
        /// Executes before Disqus comments add-on is uninstalled to remove all related data.
        /// </summary>
        public override void BeforeUninstall()
        {
            var blockType = ContentTypeRepository.Load <CommentsBlock>();

            ContentModelUsage.ListContentOfContentType(blockType)
            .Select(usage => usage.ContentLink).Distinct().ToList()
            .ForEach(contentLink => ContentRepository.Delete(contentLink, true, AccessLevel.NoAccess));

            ContentTypeRepository.Delete(blockType);

            ConfigurationProvider.Clear();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Deletes content from data base
        /// </summary>
        /// <param name="listContentId">list of content's identifiers</param>
        public void DeleteContent(string[] listContentId)
        {
            List <int> collIds = new List <int>();

            foreach (string item in listContentId)
            {
                collIds.Add(int.Parse(item));
            }

            ContentRepository     objcontent   = new ContentRepository(this.session);
            FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session);

            try
            {
                this.session.Begin();

                foreach (int item in collIds)
                {
                    string path = Path.Combine(this.context.Server.MapPath("~"), @"files\" + item);
                    if (Directory.Exists(path))
                    {
                        Directory.Delete(path, true);
                    }

                    objcontent.Entity.ContentId = item;
                    objcontent.Delete();

                    friendlyrepo.Entity.Id   = item;
                    friendlyrepo.Entity.Type = Friendlyurl.FriendlyType.Content;
                    friendlyrepo.Delete();
                }

                Utils.InsertAudit(
                    this.session,
                    new Audit()
                {
                    Joindate    = DateTime.Now,
                    Description = "Delete contents",
                    Username    = (this.context.User as CustomPrincipal).UserId,
                    Auditaction = "Delete"
                });

                this.session.Commit();
            }
            catch (Exception ex)
            {
                this.session.RollBack();
                Utils.InsertLog(this.session, "Error Delete", ex.ToString());
            }
        }
        public ActionResult Delete(int id)
        {
            service.Delete(id);

            return(RedirectToAction("Edit"));
        }
Ejemplo n.º 10
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            Entity crmPluginStep = _repository.Get("sdkmessageprocessingstep", Id);

            Mode       = Mode ?? (CrmPluginStepMode)crmPluginStep.GetAttributeValue <OptionSetValue>("mode").Value;
            Stage      = Stage ?? (CrmPluginStepStage)crmPluginStep.GetAttributeValue <OptionSetValue>("stage").Value;
            Deployment = Deployment ?? (CrmPluginStepDeployment)crmPluginStep.GetAttributeValue <OptionSetValue>("supporteddeployment").Value;

            if (Mode == CrmPluginStepMode.Asynchronous && Stage != CrmPluginStepStage.PostOperation)
            {
                throw new Exception("Asynchronous Execution Mode requires registration in one of the Post Stages. Please change the Mode or the Stage.");
            }
            if (!string.IsNullOrWhiteSpace(SecureConfig) && (Deployment == CrmPluginStepDeployment.OfflineOnly || Deployment == CrmPluginStepDeployment.Both))
            {
                throw new Exception("Secure Configuration is not supported for Steps deployed Offline.");
            }

            EntityReference crmMessageFilterReference = crmPluginStep.GetAttributeValue <EntityReference>("sdkmessagefilterid");
            Entity          crmMessageFilter          = _repository.Get(crmMessageFilterReference.LogicalName, crmMessageFilterReference.Id);

            int filterAvailability = crmMessageFilter.GetAttributeValue <int>("availability");

            if (!IsDeploymentSupported(filterAvailability, Deployment.Value))
            {
                throw new Exception(string.Format("The Step must be deployed '{0}'.", Enum.GetName(typeof(CrmPluginStepDeployment), filterAvailability)));
            }

            EntityReference crmEventHandlerReference = crmPluginStep.GetAttributeValue <EntityReference>("eventhandler");

            if (crmEventHandlerReference.LogicalName.Equals("serviceendpoint", StringComparison.InvariantCultureIgnoreCase) && Mode == CrmPluginStepMode.Synchronous)
            {
                throw new Exception("Only asynchronous Steps are supported for Service Endpoint plug-ins.");
            }

            if (!string.IsNullOrWhiteSpace(Name))
            {
                if (crmPluginStep.Contains("name"))
                {
                    crmPluginStep.Attributes["name"] = Name;
                }
                else
                {
                    crmPluginStep.Attributes.Add("name", Name);
                }
            }
            if (Description != null)
            {
                string description = string.IsNullOrWhiteSpace(Description) ? null : Description;
                if (crmPluginStep.Contains("description"))
                {
                    crmPluginStep.Attributes["description"] = description;
                }
                else
                {
                    crmPluginStep.Attributes.Add("description", description);
                }
            }
            if (UnsecureConfig != null)
            {
                string unsecureConfig = string.IsNullOrWhiteSpace(UnsecureConfig) ? null : UnsecureConfig;
                if (crmPluginStep.Contains("configuration"))
                {
                    crmPluginStep.Attributes["configuration"] = unsecureConfig;
                }
                else
                {
                    crmPluginStep.Attributes.Add("configuration", unsecureConfig);
                }
            }
            if (ExecutionOrder.HasValue)
            {
                if (crmPluginStep.Contains("rank"))
                {
                    crmPluginStep.Attributes["rank"] = ExecutionOrder.Value;
                }
                else
                {
                    crmPluginStep.Attributes.Add("rank", ExecutionOrder.Value);
                }
            }
            if (DeleteAsyncOperation.IsPresent)
            {
                if (crmPluginStep.Contains("asyncautodelete"))
                {
                    crmPluginStep.Attributes["asyncautodelete"] = DeleteAsyncOperation.ToBool();
                }
                else
                {
                    crmPluginStep.Attributes.Add("asyncautodelete", DeleteAsyncOperation.ToBool());
                }
            }
            if (User != null)
            {
                if (User.Value != Guid.Empty)
                {
                    if (crmPluginStep.Contains("impersonatinguserid"))
                    {
                        crmPluginStep.Attributes["impersonatinguserid"] = new EntityReference("systemuser", User.Value);
                    }
                    else
                    {
                        crmPluginStep.Attributes.Add("impersonatinguserid", new EntityReference("systemuser", User.Value));
                    }
                }
                else
                {
                    if (crmPluginStep.Contains("impersonatinguserid"))
                    {
                        crmPluginStep.Attributes["impersonatinguserid"] = null;
                    }
                    else
                    {
                        crmPluginStep.Attributes.Add("impersonatinguserid", null);
                    }
                }
            }
            if (Attributes != null)
            {
                EntityReference crmMessageReference = crmPluginStep.GetAttributeValue <EntityReference>("sdkmessageid");
                if (crmMessageReference.Name.Equals("update", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (Attributes.Length != 0)
                    {
                        string filteringAttributes = string.Join(",", Attributes);
                        if (crmPluginStep.Contains("filteringattributes"))
                        {
                            crmPluginStep.Attributes["filteringattributes"] = filteringAttributes;
                        }
                        else
                        {
                            crmPluginStep.Attributes.Add("filteringattributes", filteringAttributes);
                        }
                    }
                    else
                    {
                        if (crmPluginStep.Contains("filteringattributes"))
                        {
                            crmPluginStep.Attributes["filteringattributes"] = null;
                        }
                        else
                        {
                            crmPluginStep.Attributes.Add("filteringattributes", null);
                        }
                    }
                }
            }
            crmPluginStep.Attributes["mode"]  = new OptionSetValue((int)Mode);
            crmPluginStep.Attributes["stage"] = new OptionSetValue((int)Stage);
            crmPluginStep.Attributes["supporteddeployment"] = new OptionSetValue((int)Deployment);

            EntityReference crmSecureConfigReference = crmPluginStep.GetAttributeValue <EntityReference>("sdkmessageprocessingstepsecureconfigid");

            if (SecureConfig != null)
            {
                if (!string.IsNullOrWhiteSpace(SecureConfig))
                {
                    if (crmSecureConfigReference != null)
                    {
                        _repository.Update(crmSecureConfigReference.LogicalName, crmSecureConfigReference.Id, new System.Collections.Hashtable()
                        {
                            { "secureconfig", SecureConfig }
                        });
                    }
                    else
                    {
                        Guid secureConfigId = _repository.Add("sdkmessageprocessingstepsecureconfig", Guid.Empty, new System.Collections.Hashtable()
                        {
                            { "secureconfig", SecureConfig }
                        });
                        crmPluginStep.Attributes.Add("sdkmessageprocessingstepsecureconfigid", new EntityReference("sdkmessageprocessingstepsecureconfig", secureConfigId));
                    }
                }
                else
                {
                    if (crmSecureConfigReference != null)
                    {
                        crmPluginStep.Attributes["sdkmessageprocessingstepsecureconfigid"] = null;
                    }
                }
            }

            _repository.Update(crmPluginStep);
            if (SecureConfig != null && string.IsNullOrWhiteSpace(SecureConfig) && crmSecureConfigReference != null)
            {
                _repository.Delete(crmSecureConfigReference.LogicalName, crmSecureConfigReference.Id);
            }

            if (PassThru)
            {
                WriteObject(_repository.Get("sdkmessageprocessingstep", Id));
            }
        }
Ejemplo n.º 11
0
 public virtual void Cleanup()
 {
     ContentRepository.DeleteChildren(TestRootLink, true, AccessLevel.NoAccess);
     ContentRepository.Delete(TestRootLink, true);
 }