本文整理汇总了C#中Page.SetImagePath方法的典型用法代码示例。如果您正苦于以下问题:C# Page.SetImagePath方法的具体用法?C# Page.SetImagePath怎么用?C# Page.SetImagePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page.SetImagePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PageNew
//.........这里部分代码省略.........
IList<Blog.Model.Domain.Entities.Blog> tmpBlogs = br.FindAll().ToList();
if (tmpBlogs != null && tmpBlogs.Count > 0)
{
IEnumerable<SelectListItem> tmpBlogsItems;
tmpBlogsItems = from b in tmpBlogs
select new SelectListItem
{
Text = b.Name,
Value = b.Id.ToString()
};
model.Blogs = tmpBlogsItems;
}
IList<Category> tmpCategories = cr.FindAll().ToList();
if (tmpCategories != null && tmpCategories.Count > 0)
{
IEnumerable<SelectListItem> tmpCategoriesItems;
tmpCategoriesItems = from b in tmpCategories
select new SelectListItem
{
Text = b.Name,
Value = b.Id.ToString()
};
model.Categories = tmpCategoriesItems;
}
}
if (ModelState.IsValid)
{
using (UnitOfWork uow = new UnitOfWork())
{
string fileName = null;
if (model.File != null && model.File.ContentLength > 0)
{
//SALVA IL FILE
fileName = Path.GetFileName(model.File.FileName);
var path = Path.Combine(Server.MapPath("/Uploads"), fileName);
model.File.SaveAs(path);
model.FileName = fileName;
}
model.SelectedAuthor = model.SelectedAuthor;
model.SelectedBlog = model.SelectedBlog;
model.SelectedCategory = model.SelectedCategory;
PageRepository pr = new PageRepository(uow.Current);
AuthorRepository ar = new AuthorRepository(uow.Current);
BlogRepository br = new BlogRepository(uow.Current);
CategoryRepository cr = new CategoryRepository(uow.Current);
TagRepository tr = new TagRepository(uow.Current);
Author au = ar.GetById(Convert.ToInt32(model.SelectedAuthor));
Blog.Model.Domain.Entities.Blog bb = br.GetById(Convert.ToInt32(model.SelectedBlog));
Category cc = cr.GetById(Convert.ToInt32(model.SelectedCategory));
Page p = new Page(model.Titolo, model.Descrizione, model.Data, model.Body, au, bb, cc);
if (!String.IsNullOrEmpty(model.Tags))
{
foreach(var t in model.Tags.Split(','))
{
if (!String.IsNullOrEmpty(t))
{
Tag tg = tr.GetTagByName(t.TrimStart().TrimEnd());
if (tg != null)
{
p.AddTag(tg);
}
else
{
Tag tempTag = new Tag(t.TrimStart().TrimEnd());
p.AddTag(tempTag);
}
}
}
}
if (!String.IsNullOrEmpty(fileName))
p.SetImagePath(fileName);
else
model.FileName = p.ImageName;
pr.SaveOrUpdate(p);
uow.Commit();
model.Message = "Salvataggio eseguito con successo!";
}
}
return View(model);
}
catch (Exception ex)
{
return Error(ex);
}
}