Exemple #1
0
 public ApiBoolResponseDTO AddManagedUninstallsToTemplate(MunkiManifestManagedUnInstallEntity managedUninstall)
 {
     return(new ApiBoolResponseDTO
     {
         Value = _munkiManifestTemplateServices.AddManagedUnInstallToTemplate(managedUninstall)
     });
 }
        protected void buttonUpdate_OnClick(object sender, EventArgs e)
        {
            RequiresAuthorization(AuthorizationStrings.UpdateGlobal);

            var updateCount = 0;

            foreach (GridViewRow row in gvPkgInfos.Rows)
            {
                var enabled = (CheckBox)row.FindControl("chkSelector");
                if (enabled == null)
                {
                    continue;
                }
                if (!enabled.Checked)
                {
                    continue;
                }

                var dataKey = gvPkgInfos.DataKeys[row.RowIndex];
                if (dataKey == null)
                {
                    continue;
                }

                var managedUninstall = new MunkiManifestManagedUnInstallEntity
                {
                    Name = dataKey.Value.ToString(),
                    ManifestTemplateId = ManifestTemplate.Id
                };

                var cbUseVersion = (CheckBox)row.FindControl("chkUseVersion");
                if (cbUseVersion.Checked)
                {
                    managedUninstall.Version        = row.Cells[2].Text;
                    managedUninstall.IncludeVersion = 1;
                }

                var condition = (TextBox)row.FindControl("txtCondition");
                managedUninstall.Condition = condition.Text;
                if (Call.MunkiManifestTemplateApi.AddManagedUninstallsToTemplate(managedUninstall))
                {
                    updateCount++;
                }
            }

            if (updateCount > 0)
            {
                EndUserMessage = "Successfully Updated Managed Uninstalls";
                ManifestTemplate.ChangesApplied = 0;
                Call.MunkiManifestTemplateApi.Put(ManifestTemplate.Id, ManifestTemplate);
            }
            else
            {
                EndUserMessage = "Could Not Update Managed Uninstalls";
            }

            PopulateGrid();
        }
        public bool AddManagedUninstallsToTemplate(MunkiManifestManagedUnInstallEntity managedUninstall)
        {
            Request.Method   = Method.POST;
            Request.Resource = string.Format("api/{0}/AddManagedUninstallsToTemplate/", Resource);
            Request.AddJsonBody(managedUninstall);
            var response = _apiRequest.Execute <ApiBoolResponseDTO>(Request);

            return(response != null && response.Value);
        }
        public bool AddManagedUnInstallToTemplate(MunkiManifestManagedUnInstallEntity managedUnInstall)
        {
            if (
                !_uow.MunkiManagedUnInstallRepository.Exists(
                    s => s.Name == managedUnInstall.Name && s.ManifestTemplateId == managedUnInstall.ManifestTemplateId))
            {
                _uow.MunkiManagedUnInstallRepository.Insert(managedUnInstall);
            }
            else
            {
                managedUnInstall.Id =
                    _uow.MunkiManagedUnInstallRepository.GetFirstOrDefault(
                        s =>
                        s.Name == managedUnInstall.Name &&
                        s.ManifestTemplateId == managedUnInstall.ManifestTemplateId).Id;
                _uow.MunkiManagedUnInstallRepository.Update(managedUnInstall, managedUnInstall.Id);
            }

            _uow.Save();
            return(true);
        }