protected void ButtonAddComputer_Click(object sender, EventArgs e) { RequiresAuthorization(Authorizations.CreateComputer); var computer = new Computer { Name = txtComputerName.Text, Mac = txtComputerMac.Text, 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 }; var result = BLL.Computer.AddComputer(computer); if (!result.IsValid) EndUserMessage = result.Message; else { EndUserMessage = "Successfully Created Computer"; if (!createAnother.Checked) Response.Redirect("~/views/computers/edit.aspx?computerid=" + computer.Id); } }
public void Page_Load(object sender, EventArgs e) { computerBasePage = (Page as Computers); Computer = computerBasePage.Computer; if (Computer == null) Response.Redirect("~/", true); }
protected void buttonUpdateComputer_Click(object sender, EventArgs e) { RequiresAuthorizationOrManagedComputer(Authorizations.UpdateComputer, Computer.Id); var computer = new Computer { Id = Computer.Id, Name = txtComputerName.Text, Mac = txtComputerMac.Text, 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, ProxyReservation = Computer.ProxyReservation }; var result = BLL.Computer.UpdateComputer(computer); EndUserMessage = !result.IsValid ? result.Message : "Successfully Updated Computer"; }
public string AddComputer(string name, string mac) { var computer = new Models.Computer { Name = name, Mac = mac, }; var result = BLL.Computer.AddComputer(computer); return JsonConvert.SerializeObject(result); }
public void Page_Load(object sender, EventArgs e) { computerBasePage = (Page as Computers); Computer = computerBasePage.Computer; if (Computer == null) { Response.Redirect("~/", true); } }
public string AddComputer(string name, string mac) { var computer = new Models.Computer { Name = name, Mac = mac, }; var result = BLL.Computer.AddComputer(computer); return(JsonConvert.SerializeObject(result)); }
protected override void OnInit(EventArgs e) { base.OnInit(e); Computer = !string.IsNullOrEmpty(Request.QueryString["computerid"]) ? BLL.Computer.GetComputer(Convert.ToInt32(Request.QueryString["computerid"])) : null; if (Computer == null) RequiresAuthorization(Authorizations.SearchComputer); else RequiresAuthorizationOrManagedComputer(Authorizations.ReadComputer, Computer.Id); }
public static void AddComputerToSmartGroups(Models.Computer computer) { var groups = SearchGroups(); foreach (var group in groups.Where(x => x.Type == "smart")) { var computers = BLL.Computer.SearchComputersByName(group.SmartCriteria, Int32.MaxValue).Where(x => x.Name == computer.Name); var memberships = computers.Select(comp => new Models.GroupMembership { GroupId = @group.Id, ComputerId = comp.Id }).ToList(); BLL.GroupMembership.AddMembership(memberships); } }
protected void Page_Load(object sender, EventArgs e) { ComputerBasePage = (Page as Computers); Computer = ComputerBasePage.Computer; if (Computer == null) //level 2 { Level2.Visible = false; Level3.Visible = false; actions_left.Visible = false; } else { Level1.Visible = false; if (Request.QueryString["level"] == "3") Level2.Visible = false; } }
public Models.ValidationResult Put(Models.Computer value) { BLL.Authorize.ApiAuth(); return(BLL.Computer.UpdateComputer(value)); }