public ActionResultDTO Post(ComputerMunkiEntity computerMunki) { var result = _computerMunkiServices.AddMunkiTemplates(computerMunki); if (result == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(result); }
public ActionResultDTO AddMunkiTemplates(ComputerMunkiEntity computerMunki) { var actionResult = new ActionResultDTO(); _uow.ComputerMunkiRepository.Insert(computerMunki); _uow.Save(); actionResult.Success = true; actionResult.Id = computerMunki.Id; return(actionResult); }
public ActionResultDTO Post(ComputerMunkiEntity tObject) { Request.Method = Method.POST; Request.AddJsonBody(tObject); Request.Resource = string.Format("api/{0}/Post/", Resource); var response = _apiRequest.Execute <ActionResultDTO>(Request); if (response.Id == 0) { response.Success = false; } return(response); }
protected void btnAddSelected_OnClick(object sender, EventArgs e) { RequiresAuthorizationOrManagedGroup(AuthorizationStrings.UpdateComputer, Computer.Id); var list = new List <ComputerMunkiEntity>(); foreach (GridViewRow row in gvManifestTemplates.Rows) { var cb = (CheckBox)row.FindControl("chkSelector"); if (cb == null || !cb.Checked) { continue; } var dataKey = gvManifestTemplates.DataKeys[row.RowIndex]; if (dataKey == null) { continue; } var template = new ComputerMunkiEntity { ComputerId = Computer.Id, MunkiTemplateId = Convert.ToInt32(dataKey.Value) }; list.Add(template); } Call.ComputerApi.DeleteMunkiTemplates(Computer.Id); if (list.Count > 0) { var successCount = 0; foreach (var template in list) { var result = Call.ComputerMunkiApi.Post(template); if (result.Success) { successCount++; } } EndUserMessage = string.Format("Successfully Updated {0} Munki Templates", successCount); } }