public DtoActionResult Update(EntityCustomBootMenu customBootMenu) { var u = GetCustomBootMenu(customBootMenu.Id); if (u == null) { return new DtoActionResult { ErrorMessage = "Custom Boot Menu Entry Not Found", Id = 0 } } ; var actionResult = new DtoActionResult(); var validationResult = Validate(customBootMenu, false); if (validationResult.Success) { _uow.CustomBootMenuRepository.Update(customBootMenu, u.Id); _uow.Save(); actionResult.Success = true; actionResult.Id = customBootMenu.Id; } else { return(new DtoActionResult() { ErrorMessage = validationResult.ErrorMessage }); } return(actionResult); }
protected void buttonUpdate_Click(object sender, EventArgs e) { var order = 0; if (!int.TryParse(txtOrder.Text, out order)) { EndUserMessage = "Order Not Valid"; return; } var bootEntry = new EntityCustomBootMenu() { Name = txtName.Text, Description = txtDescription.Text, Content = txtContents.Text, Type = ddlType.Text, Order = order, IsActive = chkActive.Checked, IsDefault = chkDefault.Checked }; var result = Call.CustomBootMenuApi.Post(bootEntry); if (!result.Success) { EndUserMessage = result.ErrorMessage; } else { EndUserMessage = "Successfully Added Boot Menu Entry"; Response.Redirect("~/views/admin/pxeboot/editbootentry.aspx?&entryId=" + result.Id + "&level=2"); } }
public DtoActionResult Put(int id, EntityCustomBootMenu customBootMenu) { customBootMenu.Id = id; var result = _customBootMenuService.Update(customBootMenu); if (result == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(result); }
public DtoValidationResult Validate(EntityCustomBootMenu customBootMenu, bool isNew) { var validationResult = new DtoValidationResult { Success = true }; if (string.IsNullOrEmpty(customBootMenu.Name)) { validationResult.Success = false; validationResult.ErrorMessage = "Custom Boot Menu Entry Name Is Not Valid"; return(validationResult); } if (isNew) { if (_uow.CustomBootMenuRepository.Exists(h => h.Name == customBootMenu.Name)) { validationResult.Success = false; validationResult.ErrorMessage = "A Custom Boot Menu Entry With This Name Already Exists"; return(validationResult); } } else { var original = _uow.CustomBootMenuRepository.GetById(customBootMenu.Id); if (original.Name != customBootMenu.Name) { if (_uow.CustomBootMenuRepository.Exists(h => h.Name == customBootMenu.Name)) { validationResult.Success = false; validationResult.ErrorMessage = "A Custom Boot Menu Entry With This Name Already Exists"; return(validationResult); } } } return(validationResult); }
protected override void OnInit(EventArgs e) { base.OnInit(e); //auth not checked here, to allow pxe updates / gen by non admin ImpersonationAccount = !string.IsNullOrEmpty(Request["impersonationId"]) ? Call.ImpersonationAccountApi.Get(Convert.ToInt32(Request.QueryString["impersonationId"])) : null; ComServer = !string.IsNullOrEmpty(Request["serverId"]) ? Call.ClientComServerApi.Get(Convert.ToInt32(Request.QueryString["serverId"])) : null; ComServerCluster = !string.IsNullOrEmpty(Request["clusterId"]) ? Call.ComServerClusterApi.Get(Convert.ToInt32(Request.QueryString["clusterId"])) : null; WolRelay = !string.IsNullOrEmpty(Request["relayId"]) ? Call.WolRelayApi.Get(Convert.ToInt32(Request.QueryString["relayId"])) : null; BootEntry = !string.IsNullOrEmpty(Request["entryId"]) ? Call.CustomBootMenuApi.Get(Convert.ToInt32(Request.QueryString["entryId"])) : null; }
public DtoActionResult Add(EntityCustomBootMenu customBootMenu) { var actionResult = new DtoActionResult(); var validationResult = Validate(customBootMenu, true); if (validationResult.Success) { _uow.CustomBootMenuRepository.Insert(customBootMenu); _uow.Save(); actionResult.Success = true; actionResult.Id = customBootMenu.Id; } else { return(new DtoActionResult() { ErrorMessage = validationResult.ErrorMessage }); } return(actionResult); }
public DtoActionResult Post(EntityCustomBootMenu customBootMenu) { return(_customBootMenuService.Add(customBootMenu)); }