private bool SaveItem() { bool success = false; try { bool isUpdate = (IView == ItemView.Edit); item = (isUpdate) ? new SPA.Redirect(ItemID) : new SPA.Redirect(); item.HostNameID = int.Parse(ddlHostName.SelectedValue); item.OriginalUrl = txtSourceUrl.Text.Trim(); item.NewUrl = txtDestinationUrl.Text.Trim(); item.Enabled = ckbxEnable.Checked; item.ModifiedBy = CurrentUser.UserName; if (!isUpdate) { item.CreatedBy = item.ModifiedBy; if (item.Insert()) { success = true; Action.Write(string.Format("Created Redirect for https://{0}/{1}", new HostName(item.HostNameID).Name, item.OriginalUrl), CurrentUser.UserName); } } else { if (item.Update()) { success = true; Action.Write(string.Format("Updated Redirect for https://{0}/{1}", new HostName(item.HostNameID).Name, item.OriginalUrl), CurrentUser.UserName); } } ItemID = (success) ? item.ID : 0; } catch (Exception ex) { SPA.Error.WriteError(ex); if (ShowDebug) { lblErrorMessage.Text = ex.ToString(); } } return(success); }
public bool DisableRedirect(int ID, string Key) { bool successful = false; string storedKey = SPA.Configuration.AppSetting("AccessKey"); CurrentUser = new SPA.User(Context.User.Identity.Name); if (storedKey.Length > 0 && Key == storedKey) { Redirect redirect = new Redirect(ID); redirect.Enabled = false; if (redirect.Update()) { Action.Write(string.Format("Redirect to {0} from {1} disabled via web services", redirect.NewUrl, redirect.OriginalUrl), CurrentUser.DisplayName); successful = true; } else { Action.Write(string.Format("Redirect to {0} from {1} FAILED to disable via web services", redirect.NewUrl, redirect.OriginalUrl), CurrentUser.DisplayName); } } return(successful); }