protected void btnSubmit_OnClick(object sender, EventArgs e) { RequiresAuthorization(AuthorizationStrings.CreateGlobal); var bootEntry = new BootEntryEntity { Name = txtName.Text, Description = txtDescription.Text, Content = txtContents.Text, Type = ddlType.Text, Order = txtOrder.Text, Active = chkActive.Checked ? 1 : 0, Default = chkDefault.Checked ? 1 : 0 }; var result = Call.BootEntryApi.Post(bootEntry); if (!result.Success) { EndUserMessage = result.ErrorMessage; } else { EndUserMessage = "Successfully Added Boot Menu Entry"; Response.Redirect("~/views/admin/bootmenu/editentry.aspx?&entryid=" + result.Id); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); RequiresAuthorization(AuthorizationStrings.ReadAdmin); BootEntry = !string.IsNullOrEmpty(Request["entryid"]) ? Call.BootEntryApi.Get(Convert.ToInt32(Request.QueryString["entryid"])) : null; }
public ActionResultDTO Put(int id, BootEntryEntity bootEntry) { bootEntry.Id = id; var result = _bootEntryServices.UpdateBootEntry(bootEntry); if (result.Id == 0) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, result)); } return(result); }
public ActionResultDTO Put(int id, BootEntryEntity 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 ActionResultDTO AddBootEntry(BootEntryEntity bootEntry) { var validationResult = ValidateEntry(bootEntry, true); var actionResult = new ActionResultDTO(); if (validationResult.Success) { _uow.BootEntryRepository.Insert(bootEntry); _uow.Save(); actionResult.Success = true; actionResult.Id = bootEntry.Id; } return(actionResult); }
private ValidationResultDTO ValidateEntry(BootEntryEntity bootEntry, bool isNewEntry) { var validationResult = new ValidationResultDTO { Success = true }; if (string.IsNullOrEmpty(bootEntry.Name)) { validationResult.Success = false; validationResult.ErrorMessage = "Boot Entry Name Is Not Valid"; return(validationResult); } if (isNewEntry) { using (var uow = new UnitOfWork()) { if (uow.BootEntryRepository.Exists(h => h.Name == bootEntry.Name)) { validationResult.Success = false; validationResult.ErrorMessage = "This Boot Entry Already Exists"; return(validationResult); } } } else { using (var uow = new UnitOfWork()) { var originalTemplate = uow.BootEntryRepository.GetById(bootEntry.Id); if (originalTemplate.Name != bootEntry.Name) { if (uow.BootEntryRepository.Exists(h => h.Name == bootEntry.Name)) { validationResult.Success = false; validationResult.ErrorMessage = "This Boot Template Already Exists"; return(validationResult); } } } } return(validationResult); }
protected void btnSubmit_OnClick(object sender, EventArgs e) { RequiresAuthorization(AuthorizationStrings.UpdateGlobal); var bootEntry = new BootEntryEntity { Id = BootEntry.Id, Name = txtName.Text, Description = txtDescription.Text, Content = txtContents.Text, Type = ddlType.Text, Order = txtOrder.Text, Active = chkActive.Checked ? 1 : 0, Default = chkDefault.Checked ? 1 : 0 }; var result = Call.BootEntryApi.Put(bootEntry.Id, bootEntry); EndUserMessage = !result.Success ? result.ErrorMessage : "Successfully Updated Boot Menu Entry"; }
public ActionResultDTO UpdateBootEntry(BootEntryEntity bootEntry) { var validationResult = ValidateEntry(bootEntry, false); var actionResult = new ActionResultDTO(); if (validationResult.Success) { _uow.BootEntryRepository.Update(bootEntry, bootEntry.Id); _uow.Save(); actionResult.Success = true; actionResult.Id = bootEntry.Id; } else { actionResult.ErrorMessage = validationResult.ErrorMessage; } return(actionResult); }
public ActionResultDTO Post(BootEntryEntity bootEntry) { return(_bootEntryServices.AddBootEntry(bootEntry)); }