Esempio n. 1
0
 public ApiBoolResponseDTO AddOptionalInstallToTemplate(MunkiManifestOptionInstallEntity optionalInstall)
 {
     return(new ApiBoolResponseDTO
     {
         Value = _munkiManifestTemplateServices.AddOptionalInstallToTemplate(optionalInstall)
     });
 }
        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 optionalInstall = new MunkiManifestOptionInstallEntity
                {
                    Name = dataKey.Value.ToString(),
                    ManifestTemplateId = ManifestTemplate.Id
                };

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

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

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

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

            return(response != null && response.Value);
        }
        public bool AddOptionalInstallToTemplate(MunkiManifestOptionInstallEntity optionalInstall)
        {
            if (
                !_uow.MunkiOptionalInstallRepository.Exists(
                    s => s.Name == optionalInstall.Name && s.ManifestTemplateId == optionalInstall.ManifestTemplateId))
            {
                _uow.MunkiOptionalInstallRepository.Insert(optionalInstall);
            }
            else
            {
                optionalInstall.Id =
                    _uow.MunkiOptionalInstallRepository.GetFirstOrDefault(
                        s =>
                        s.Name == optionalInstall.Name && s.ManifestTemplateId == optionalInstall.ManifestTemplateId)
                    .Id;
                _uow.MunkiOptionalInstallRepository.Update(optionalInstall, optionalInstall.Id);
            }

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