本文整理汇总了C#中Category.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Category.Save方法的具体用法?C# Category.Save怎么用?C# Category.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditCategory_Click
protected void EditCategory_Click(object sender, EventArgs e)
{
try
{
Category c = new Category(Request.QueryString["id"]);
c.Name = Server.HtmlEncode(txtExistingCategory.Text.Trim());
c.FormattedName = txtExistingLinkName.Text.Trim();
c.Body = Editor.Text;
c.FeedUrlOverride = txtFeedBurner.Text;
c.MetaDescription = Server.HtmlEncode(txtMetaScription.Text.Trim());
c.MetaKeywords = Server.HtmlEncode(txtKeywords.Text.Trim());
c.SortOrder = (SortOrderType)Enum.Parse(typeof(SortOrderType), SortOrder.SelectedValue, true);
c.Save();
Response.Redirect("~/graffiti-admin/categories/?upd=" + c.Name);
}
catch (Exception ex)
{
string exMessage = ex.Message;
if (!string.IsNullOrEmpty(exMessage) && exMessage.IndexOf("UNIQUE") > -1)
exMessage = "This category already exists";
Message.Text = "A category with the name of " + txtExistingCategory.Text + " could not be created <br />" +
exMessage;
Message.Type = StatusType.Error;
}
}
示例2: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
Category objCategory = new Category();
objCategory.CategoryId = Int32.Parse(hdnCategory.Value.Trim());
objCategory.CategoryType = txtCatType.Text.Trim();
objCategory.CategoryDesc = txtDescription.Text.Trim();
if (!(new CategoryDAO()).IsCategoryExists(txtCatType.Text.Trim()))
{
if (objCategory.Save())
{
lblError.Visible = true;
lblError.Text = Constant.MSG_Save_SavedSeccessfully;
}
}
else
{
lblError.Visible = true;
lblError.Text = Constant.Error_Category_Exists;
}
}
catch (Exception ex)
{
ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void btnSave_Click(object sender, EventArgs e)");
if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty)
Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false);
else
Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false);
}
}
示例3: btnAdd_Click
/// <summary>
/// Handles the Click event of the btnAdd control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected void btnAdd_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
Category cat = new Category(txtNewCategory.Text, txtNewNewDescription.Text);
cat.Save();
Response.Redirect(Request.RawUrl, true);
}
}
示例4: AddCategory
public void AddCategory(Category category)
{
if (category == null)
{
throw new ArgumentNullException("category");
}
category.Save();
}
示例5: AddButton_Click
protected void AddButton_Click(object obj, EventArgs args)
{
if (Page.IsValid == false)
return;
if (CurrentProject != null)
{
bool wasCategorySave = false;
Category newCategory = new Category(Abbrev.Text, Convert.ToDecimal(CatDuration.Text), CategoryName.Text, CurrentProject.Id);
wasCategorySave = newCategory.Save();
ListAllCategories.DataBind();
}
}
示例6: btnSaveSEO_Click
protected void btnSaveSEO_Click(object sender, EventArgs e)
{
Category cat = new Category();
if (cat.LoadByPrimaryKey(CategoryID))
{
cat.s_Keywords = tbKeywords.Text;
cat.s_Keywords_pl = tbKeywords_pl.Text;
cat.s_Keywords_en = tbKeywords_en.Text;
cat.s_Description = tbDescription.Text;
cat.s_Description_pl = tbDescription_pl.Text;
cat.s_Description_en = tbDescription_en.Text;
cat.Save();
}
RedirectBackToList();
}
示例7: btnAdd_Click
/// <summary>
/// Handles the Click event of the btnAdd control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
void btnAdd_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string description = txtNewNewDescription.Text;
if (description.Length > 255)
description = description.Substring(0, 255);
Category cat = new Category(txtNewCategory.Text, description);
if (ddlNewParent.SelectedValue != "0")
cat.Parent = new Guid(ddlNewParent.SelectedValue);
cat.Save();
Response.Redirect(Request.RawUrl, true);
}
}
示例8: CopyButton_Click
protected void CopyButton_Click(object obj, EventArgs args)
{
if (CurrentProject != null)
{
int selectedProjectId = Convert.ToInt32(ProjectList.SelectedValue);
List<Category> newCategories = Category.GetCategoriesByProjectId(selectedProjectId);
foreach (Category cat in newCategories)
{
Category newCat = new Category(cat.Abbreviation, cat.EstimateDuration, cat.Name, CurrentProject.Id);
newCat.Save();
}
CategoryData.DataBind();
ListAllCategories.DataBind();
}
}
示例9: HomeModule
public HomeModule()
{
Get["/"] = _ => {
List<Category> AllCategories = Category.GetAll();
return View["index.cshtml", AllCategories];
};
Get["/tasks"] = _ => {
List<Task> AllTasks = Task.GetAll();
return View["tasks.cshtml", AllTasks];
};
Get["/categories"] = _ => {
List<Category> AllCategories = Category.GetAll();
return View["categories.cshtml", AllCategories];
};
Get["/categories/new"] = _ => {
return View["categories_form.cshtml"];
};
Post["/categories/new"] = _ => {
Category newCategory = new Category(Request.Form["category-name"]);
newCategory.Save();
return View["success.cshtml"];
};
Get["/tasks/new"] = _ => {
List<Category> AllCategories = Category.GetAll();
return View["tasks_form.cshtml", AllCategories];
};
Post["/tasks/new"] = _ => {
Task newTask = new Task(Request.Form["task-description"], Request.Form["task-due-date"], Request.Form["category-id"]);
newTask.Save();
return View["success.cshtml"];
};
Post["/tasks/delete"] = _ => {
Task.DeleteAll();
return View["cleared.cshtml"];
};
Get["/categories/{id}"] = parameters => {
Dictionary<string, object> model = new Dictionary<string, object>();
var SelectedCategory = Category.Find(parameters.id);
var CategoryTasks = SelectedCategory.GetTasks();
model.Add("category", SelectedCategory);
model.Add("tasks", CategoryTasks);
return View["category.cshtml", model];
};
}
示例10: uiButtonUpdate_Click
protected void uiButtonUpdate_Click(object sender, EventArgs e)
{
Category cat = new Category();
if (CurrentCategory != null)
{
cat = CurrentCategory;
}
else
{
cat.AddNew();
}
cat.Name = uiTextBoxName.Text;
cat.Save();
uiPanelEdit.Visible = false;
uiPanelViewCats.Visible = true;
Clearfields();
BindData();
CurrentCategory = null;
}
示例11: btnAdd_Click
/// <summary>
/// Add a new category into the database
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAdd_Click(object sender, EventArgs e)
{
if (txtName.Text.Length > 0 && txtURLRewrite.Text.Length > 0)
{
Category newCat = new Category();
newCat.CatName = txtName.Text;
newCat.URLRewrite = txtURLRewrite.Text;
newCat.Lang = 1;
if (ddlParentCat.SelectedItem.Value == "NULL")
{
newCat.Parent = null;
}
else
{
newCat.Parent = ubConvert.ToInt(ddlParentCat.SelectedItem.Value);
}
newCat.Save();
txtName.Text = "";
txtURLRewrite.Text = "";
GenerateCatList();
}
}
示例12: CreateCategory_Click
protected void CreateCategory_Click(object sender, EventArgs e)
{
try
{
Category c = new Category();
c.Name = Server.HtmlEncode(txtCategory.Text.Trim());
c.ParentId = Int32.Parse(Parent_Categories.SelectedValue);
c.Save();
Response.Redirect("~/graffiti-admin/categories/?id=" + c.Id + "&new=true");
}
catch (Exception ex)
{
string exMessage = ex.Message;
if (!string.IsNullOrEmpty(exMessage) && exMessage.IndexOf("UNIQUE") > -1)
exMessage = "This category already exists";
Message.Text = "A category with the name of " + txtCategory.Text + " could not be created <br />" +
exMessage;
Message.Type = StatusType.Error;
}
}
示例13: Main
static void Main()
{
ConvertUtilities.SetCurrentThreadCulture("en-US");
Category category = new Category();
category.Name = "EN: High-Tech";
category.Save();
Category.SaveLocalizedValues(category, 1036, false, "FR: High-Tech");
Product product = new Product();
product.Name = "Phone";
product.Category = category;
product.Save();
Console.WriteLine(Product.LoadById(product.Id).Name);
Console.WriteLine(Product.LoadById(product.Id).Name);
ConvertUtilities.SetCurrentThreadCulture(1036);
Console.WriteLine(Category.Load(category.Id).Name);
Console.WriteLine(Category.Load(category.Id).Name);
ConvertUtilities.SetCurrentThreadCulture(1033);
Console.WriteLine(Category.Load(category.Id).Name);
Console.WriteLine(Category.Load(category.Id).Name);
}
示例14: EditPost
/// <summary>
/// metaWeblog.editPost method
/// </summary>
/// <param name="postId">
/// post guid in string format
/// </param>
/// <param name="userName">
/// login username
/// </param>
/// <param name="password">
/// login password
/// </param>
/// <param name="sentPost">
/// struct with post details
/// </param>
/// <param name="publish">
/// mark as published?
/// </param>
/// <returns>
/// 1 if successful
/// </returns>
internal bool EditPost(string postId, string userName, string password, MWAPost sentPost, bool publish)
{
var post = Post.GetPost(new Guid(postId));
if (!post.CanUserEdit)
{
throw new MetaWeblogException("11", "User authentication failed");
}
string author = String.IsNullOrEmpty(sentPost.author) ? userName : sentPost.author;
if (!post.IsPublished && publish)
{
if (!post.CanPublish(author))
{
throw new MetaWeblogException("11", "Not authorized to publish this Post.");
}
}
post.Author = author;
post.Title = sentPost.title;
post.Content = sentPost.description;
post.IsPublished = publish;
post.Slug = sentPost.slug;
post.Description = sentPost.excerpt;
if (sentPost.commentPolicy != string.Empty)
{
post.HasCommentsEnabled = sentPost.commentPolicy == "1";
}
post.Categories.Clear();
foreach (var item in sentPost.categories.Where(c => c != null && c.Trim() != string.Empty))
{
Category cat;
if (LookupCategoryGuidByName(item, out cat))
{
post.Categories.Add(cat);
}
else
{
// Allowing new categories to be added. (This breaks spec, but is supported via WLW)
using (var newcat = new Category(item, string.Empty))
{
newcat.Save();
post.Categories.Add(newcat);
}
}
}
post.Tags.Clear();
foreach (var item in sentPost.tags.Where(item => item != null && item.Trim() != string.Empty))
{
post.Tags.Add(item);
}
if (sentPost.postDate != new DateTime())
{
post.DateCreated = sentPost.postDate.AddHours(-BlogSettings.Instance.Timezone);
}
post.Save();
return true;
}
示例15: publish_return_click
protected void publish_return_click(object sender, EventArgs e)
{
try
{
if (!IsValid)
return;
IGraffitiUser user = GraffitiUsers.Current;
ListItem catItem = CategoryList.SelectedItem;
if (catItem.Value == "-1" && String.IsNullOrEmpty(newCategory.Text))
{
SetMessage("Please enter a name for the new Category.", StatusType.Error);
return;
}
string extenedBody = txtContent_extend.Text;
string postBody = txtContent.Text;
if (string.IsNullOrEmpty(postBody))
{
SetMessage("Please enter a post body.", StatusType.Warning);
return;
}
Category c = new Category();
if (catItem.Value == "-1")
{
try
{
Category temp = new Category();
temp.Name = newCategory.Text;
temp.Save();
c = temp;
CategoryController.Reset();
}
catch (Exception ex)
{
SetMessage("The category could not be created. Reason: " + ex.Message, StatusType.Error);
}
}
else
{
c = new CategoryController().GetCachedCategory(Int32.Parse(catItem.Value), false);
}
string pid = Request.QueryString["id"];
Post p = pid == null ? new Post() : new Post(pid);
if (p.IsNew)
{
p["where"] = "web";
p.UserName = user.Name;
if (Request.Form["dateChangeFlag"] == "true")
p.Published = PublishDate.DateTime;
else
p.Published = DateTime.Now.AddHours(SiteSettings.Get().TimeZoneOffSet);
}
else
{
p.Published = PublishDate.DateTime;
}
p.ModifiedOn = DateTime.Now.AddHours(SiteSettings.Get().TimeZoneOffSet);
p.PostBody = postBody;
if (string.IsNullOrEmpty(extenedBody) || extenedBody == "<p></p>" || extenedBody == "<p> </p>" || extenedBody == "<br />\r\n")
{
p.ExtendedBody = null;
}
else
{
p.ExtendedBody = extenedBody;
}
p.Title = Server.HtmlEncode(txtTitle.Text);
p.EnableComments = EnableComments.Checked;
p.Name = txtName.Text;
p.TagList = txtTags.Text.Trim();
p.ContentType = "text/html";
p.CategoryId = c.Id;
p.Notes = txtNotes.Text;
p.ImageUrl = postImage.Text;
p.MetaKeywords = Server.HtmlEncode(txtKeywords.Text.Trim());
p.MetaDescription = Server.HtmlEncode(txtMetaScription.Text.Trim());
p.IsHome = HomeSortOverride.Checked;
p.PostStatus = (PostStatus)Enum.Parse(typeof(PostStatus), Request.Form[PublishStatus.UniqueID]);
CustomFormSettings cfs = CustomFormSettings.Get(c);
if (cfs.HasFields)
{
foreach (CustomField cf in cfs.Fields)
{
if (cf.FieldType == FieldType.CheckBox && Request.Form[cf.Id.ToString()] == null)
p[cf.Name] = null; // false.ToString();
//.........这里部分代码省略.........