protected void Page_Load(object sender, EventArgs e) { _groupProperty = Call.GroupApi.GetGroupProperties(Group.Id); if (!IsPostBack) { PopulateForm(); } }
protected void btnSubmit_OnClick(object sender, EventArgs e) { RequiresAuthorizationOrManagedGroup(AuthorizationStrings.UpdateGroup, Group.Id); var groupProperty = new GroupPropertyEntity { GroupId = Group.Id, ImageId = Convert.ToInt32(ddlComputerImage.SelectedValue), ImageProfileId = Convert.ToInt32(ddlComputerImage.SelectedValue) == -1 ? -1 : Convert.ToInt32(ddlImageProfile.SelectedValue), Description = txtComputerDesc.Text, SiteId = Convert.ToInt32(ddlSite.SelectedValue), BuildingId = Convert.ToInt32(ddlBuilding.SelectedValue), RoomId = Convert.ToInt32(ddlRoom.SelectedValue), CustomAttribute1 = txtCustom1.Text, CustomAttribute2 = txtCustom2.Text, CustomAttribute3 = txtCustom3.Text, CustomAttribute4 = txtCustom4.Text, CustomAttribute5 = txtCustom5.Text, ImageEnabled = Convert.ToInt16(chkImage.Checked), ImageProfileEnabled = Convert.ToInt16(chkProfile.Checked), DescriptionEnabled = Convert.ToInt16(chkDescription.Checked), SiteEnabled = Convert.ToInt16(chkSite.Checked), BuildingEnabled = Convert.ToInt16(chkBuilding.Checked), RoomEnabled = Convert.ToInt16(chkRoom.Checked), CustomAttribute1Enabled = Convert.ToInt16(chkCustom1.Checked), CustomAttribute2Enabled = Convert.ToInt16(chkCustom2.Checked), CustomAttribute3Enabled = Convert.ToInt16(chkCustom3.Checked), CustomAttribute4Enabled = Convert.ToInt16(chkCustom4.Checked), CustomAttribute5Enabled = Convert.ToInt16(chkCustom5.Checked), ProxyEnabledEnabled = Convert.ToInt16(chkProxyReservation.Checked), BootFileEnabled = Convert.ToInt16(chkBootFile.Checked), TftpServerEnabled = Convert.ToInt16(chkTftp.Checked), ProxyEnabled = Convert.ToInt16(chkProxyEnabled.Checked), TftpServer = txtTftp.Text, BootFile = ddlBootFile.Text, ClusterGroupId = Convert.ToInt32(ddlClusterGroup.SelectedValue), ClusterGroupEnabled = Convert.ToInt16(chkClusterGroup.Checked), AlternateServerIpEnabled = Convert.ToInt16(chkAltServer.Checked), AlternateServerIpId = Convert.ToInt32(ddlAltServer.SelectedValue), ImageClassificationsEnabled = Convert.ToInt16(chkImageClass.Checked) }; if (_groupProperty == null) { Call.GroupPropertyApi.Post(groupProperty); EndUserMessage = "Successfully Updated Group Properties"; } else { groupProperty.Id = _groupProperty.Id; Call.GroupPropertyApi.Put(groupProperty.Id, groupProperty); EndUserMessage = "Successfully Updated Group Properties"; } }
public ActionResultDTO UpdateGroupProperty(GroupPropertyEntity groupProperty) { _uow.GroupPropertyRepository.Update(groupProperty, groupProperty.Id); _uow.Save(); var actionResult = new ActionResultDTO(); actionResult.Success = true; actionResult.Id = groupProperty.Id; UpdateComputerProperties(groupProperty); return(actionResult); }
public ActionResultDTO Put(int id, GroupPropertyEntity groupProperty) { groupProperty.Id = id; var result = _groupPropertyServices.UpdateGroupProperty(groupProperty); if (result == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(result); }
public ActionResultDTO Put(int id, GroupPropertyEntity tObject) { Request.Method = Method.PUT; Request.AddJsonBody(tObject); Request.Resource = string.Format("api/{0}/Put/{1}", Resource, id); var response = _apiRequest.Execute <ActionResultDTO>(Request); if (response.Id == 0) { response.Success = false; } return(response); }
public void UpdateComputerProperties(GroupPropertyEntity groupProperty) { if (groupProperty == null) { return; } var groupImageClassifications = new List <GroupImageClassificationEntity>(); if (Convert.ToBoolean(groupProperty.ImageClassificationsEnabled)) { groupImageClassifications = new GroupServices().GetGroupImageClassifications(groupProperty.GroupId); } foreach (var computer in new GroupServices().GetGroupMembersWithImages(groupProperty.GroupId)) { if (Convert.ToBoolean(groupProperty.ImageEnabled)) { computer.ImageId = groupProperty.ImageId; } if (Convert.ToBoolean(groupProperty.ImageProfileEnabled)) { computer.ImageProfileId = groupProperty.ImageProfileId; } if (Convert.ToBoolean(groupProperty.DescriptionEnabled)) { computer.Description = groupProperty.Description; } if (Convert.ToBoolean(groupProperty.SiteEnabled)) { computer.SiteId = groupProperty.SiteId; } if (Convert.ToBoolean(groupProperty.BuildingEnabled)) { computer.BuildingId = groupProperty.BuildingId; } if (Convert.ToBoolean(groupProperty.RoomEnabled)) { computer.RoomId = groupProperty.RoomId; } if (Convert.ToBoolean(groupProperty.CustomAttribute1Enabled)) { computer.CustomAttribute1 = groupProperty.CustomAttribute1; } if (Convert.ToBoolean(groupProperty.CustomAttribute2Enabled)) { computer.CustomAttribute2 = groupProperty.CustomAttribute2; } if (Convert.ToBoolean(groupProperty.CustomAttribute3Enabled)) { computer.CustomAttribute3 = groupProperty.CustomAttribute3; } if (Convert.ToBoolean(groupProperty.CustomAttribute4Enabled)) { computer.CustomAttribute4 = groupProperty.CustomAttribute4; } if (Convert.ToBoolean(groupProperty.CustomAttribute5Enabled)) { computer.CustomAttribute5 = groupProperty.CustomAttribute5; } if (Convert.ToBoolean(groupProperty.ProxyEnabledEnabled)) { computer.ProxyReservation = groupProperty.ProxyEnabled; } if (Convert.ToBoolean(groupProperty.ClusterGroupEnabled)) { computer.ClusterGroupId = groupProperty.ClusterGroupId; } if (Convert.ToBoolean(groupProperty.AlternateServerIpEnabled)) { computer.AlternateServerIpId = groupProperty.AlternateServerIpId; } if (Convert.ToBoolean(groupProperty.ImageClassificationsEnabled)) { var computerImageClassifications = new List <ComputerImageClassificationEntity>(); if (new ComputerServices().DeleteComputerImageClassifications(computer.Id)) { foreach (var imageClass in groupImageClassifications) { computerImageClassifications.Add( new ComputerImageClassificationEntity { ComputerId = computer.Id, ImageClassificationId = imageClass.ImageClassificationId }); } } new ComputerImageClassificationServices().AddClassifications(computerImageClassifications); } var computerServices = new ComputerServices(); computerServices.UpdateComputer(computer); if (Convert.ToBoolean(groupProperty.TftpServerEnabled) || Convert.ToBoolean(groupProperty.BootFileEnabled)) { var proxyServices = new ComputerProxyReservationServices(); var computerProxy = computerServices.GetComputerProxyReservation(computer.Id); if (computerProxy == null) { computerProxy = new ComputerProxyReservationEntity(); computerProxy.ComputerId = computer.Id; } if (Convert.ToBoolean(groupProperty.TftpServerEnabled)) { computerProxy.NextServer = groupProperty.TftpServer; } if (Convert.ToBoolean(groupProperty.BootFileEnabled)) { computerProxy.BootFile = groupProperty.BootFile; } proxyServices.UpdateComputerProxyReservation(computerProxy); } } }
public ActionResultDTO Post(GroupPropertyEntity groupProperty) { return(_groupPropertyServices.AddGroupProperty(groupProperty)); }