public ActionResult Create(FormCollection form, int brandId, IEnumerable<HttpPostedFileBase> fileUpload, IList<string> fileTitles, string filter) { try { using (var context = new CatalogueContainer()) { var brand = context.Brand.Include("Category").First(b => b.Id == brandId); foreach (var file in fileUpload) { if (file != null) { var product = new Product { Brand = brand }; string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName); string filePath = Server.MapPath("~/Content/Images"); filePath = Path.Combine(filePath, fileName); file.SaveAs(filePath); product.ImageSource = fileName; context.AddToProduct(product); } } context.SaveChanges(); return RedirectToAction("Index", "Catalogue", new { Area = "", brand = brand.Name, category=brand.Category.Name, filter = filter }); } } catch { return View(); } }
public ActionResult Edit(int id, FormCollection form, string filter) { using (var context = new CatalogueContainer()) { var brand = context.Brand.Include("Category").First(b => b.Id == id); //var category = context.Category.Include("CategoryAttributes").First(c => c.Id == brand.CategoryId); brand.CategoryAttributes.Clear(); PostCheckboxesData cbData = form.ProcessPostCheckboxesData("attr"); foreach (var kvp in cbData) { var attrId = kvp.Key; bool attrValue = kvp.Value; if (attrValue) { var attribute = context.CategoryAttribute.First(c => c.Id == attrId); brand.CategoryAttributes.Add(attribute); } } string categoryName = brand.Category.Name; TryUpdateModel(brand, new[] { "Title", "Name", "SortOrder", "Href", "DescriptionTitle" }); brand.Name = brand.Name.ToLower().Replace(" ", ""); brand.Description = HttpUtility.HtmlDecode(form["Description"]); context.SaveChanges(); return RedirectToAction("Index", "Catalogue", new { area = "", category = categoryName,filter=filter }); } }
public ActionResult Edit(int id, FormCollection form) { try { using (var context = new CatalogueContainer()) { var project = context.Project.First(p => p.Id == id); TryUpdateModel(project, new[] { "Name", "Title", "DescriptionTitle", "SortOrder", "SeoDescription", "SeoKeywords" }); project.Description = HttpUtility.HtmlDecode(form["Description"]); project.Name = project.Name.ToLower().Replace(" ", ""); context.SaveChanges(); return RedirectToAction("Index", "Projects", new { Area = "", project = project.Name }); } } catch { return View(); } }
public ActionResult Index() { using (var context = new CatalogueContainer()) { var images = context.MainPageImage.ToList(); return View(images); } }
// // GET: /Admin/Article/Edit/5 public ActionResult Edit(int id) { using (var context = new CatalogueContainer()) { var article = context.Article.First(a => a.Id == id); return View(article); } }
// // GET: /Admin/Project/Edit/5 public ActionResult Edit(int id) { using (var context = new CatalogueContainer()) { var project = context.Project.First(p => p.Id == id); return View(project); } }
public ActionResult Edit(int id) { using (var context = new CatalogueContainer()) { var content = context.Content.First(c => c.Id == id); return View(content); } }
public ActionResult Edit(int id) { using (var context = new CatalogueContainer()) { var attribute = context.CategoryAttribute.First(a => a.Id == id); return View(attribute); } }
public ActionResult Create(int id, string filter) { using (var context = new CatalogueContainer()) { var brand = context.Brand.First(c => c.Id == id); ViewBag.Filter = filter; return View(new Product { Brand = brand }); } }
public ActionResult Create() { using (var context = new CatalogueContainer()) { var category = new Category { SortOrder = 0 }; var attributes = context.CategoryAttribute.ToList(); ViewBag.Attributes = attributes; return View(category); } }
public ActionResult Index() { using (var context = new CatalogueContainer()) { ViewBag.Categories = context.Category.ToList(); ViewBag.Projects = context.Project.ToList(); var pa = context.CategoryAttribute.ToList(); return View(pa); } }
// // GET: /Admin/Article/Delete/5 public ActionResult Delete(int id) { using (var context = new CatalogueContainer()) { var article = context.Article.First(a => a.Id == id); context.DeleteObject(article); context.SaveChanges(); return RedirectToAction("Index", "Articles", new { area = "" }); } }
public SiteViewModel(CatalogueContainer context, string contentName) { var categories = context.Category.ToList(); Categories = categories; var projects = context.Project.ToList(); Projects = projects; var contents = context.Content.Where(c => !c.MainPage).ToList(); Menu = new Menu(); foreach (var content in contents) { Menu.Add(new MenuItem { ContentId = content.Id, ContentName = content.Name, Current = content.Name == contentName, SortOrder = content.SortOrder, Title = content.Title }); } if (contentName == null) { Content = context.Content.First(c => c.MainPage); if (context.MainPageImage.FirstOrDefault() != null) { MainPageImage = context.MainPageImage.RandomElement(new Random()); //MainPageImages = context.MainPageImage.ToList(); } } else { Content = context.Content.FirstOrDefault(c => c.Name == contentName); if (Content == null) { throw new HttpNotFoundException(); } } Title = Content.Title; SeoDescription = Content.SeoDescription; SeoKeywords = Content.SeoKeywords; if (Content.MainPage) { IsHomePage = true; //Layouts = context.Layout.Include("Parent").Include("Children").ToList(); } }
public ActionResult Create(int id, string filter) { using (var context = new CatalogueContainer()) { var category = context.Category.Include("CategoryAttributes").First(c => c.Id == id); ViewBag.CategoryAttributes = category.CategoryAttributes.ToList(); ViewBag.CategoryId = id; ViewBag.Filter = filter; return View(new Brand{Category = category}); } }
public ActionResult Delete(int id) { using (var context = new CatalogueContainer()) { var attribute = context.CategoryAttribute.First(a => a.Id == id); attribute.Categories.Clear(); attribute.Brands.Clear(); context.DeleteObject(attribute); context.SaveChanges(); } return RedirectToAction("Index"); }
// // GET: /Articles/ public ActionResult Index() { using (var context = new CatalogueContainer()) { var model = new ArticlesViewModel(context); ViewBag.Categories = model.Categories; ViewBag.Projects = model.Projects; this.SetSeoContent(model); ViewBag.MainMenu = model.Menu; ViewBag.IsArticles = true; return View(model); } }
public ActionResult Edit(int id, string filter) { using (var context = new CatalogueContainer()) { ViewBag.Filter = filter; var brand = context.Brand.Include("Category").Include("CategoryAttributes").First(l => l.Id == id); var category = context.Category.Include("CategoryAttributes").First(c => c.Id == brand.CategoryId); ViewBag.CategoryAttributes = category.CategoryAttributes.ToList(); ViewBag.SelectedAttributes = brand.CategoryAttributes.ToList(); return View(brand); } }
// // GET: /Projects/ public ActionResult Index(string project) { using (var context = new CatalogueContainer()) { var model = new ProjectViewModel(context, project); ViewBag.Categories = model.Categories; ViewBag.Projects = model.Projects; this.SetSeoContent(model); ViewBag.MainMenu = model.Menu; ViewBag.ProjectsPage = true; return View(model); } }
public ActionResult Create(FormCollection form) { try { using (var context = new CatalogueContainer()) { var category = new Category(); var attributes = context.CategoryAttribute.ToList(); PostCheckboxesData postData = form.ProcessPostCheckboxesData("attr"); foreach (var kvp in postData) { var attribute = attributes.First(a => a.Id == kvp.Key); if (kvp.Value) { if (!category.CategoryAttributes.Contains(attribute)) category.CategoryAttributes.Add(attribute); } else { if (category.CategoryAttributes.Contains(attribute)) category.CategoryAttributes.Remove(attribute); } } TryUpdateModel(category, new[] { "Name", "Title", "SortOrder", "SeoDescription", "SeoKeywords", "DescriptionTitle" }); category.Description = HttpUtility.HtmlDecode(form["Description"]); category.Name = category.Name.ToLower().Replace(" ", ""); context.AddToCategory(category); context.SaveChanges(); return RedirectToAction("Index", "Category", new { area = "Admin" }); } } catch { return View(); } }
public ActionResult Edit(int id, FormCollection form) { try { using (var context = new CatalogueContainer()) { var attribute = context.CategoryAttribute.First(a => a.Id == id); TryUpdateModel(attribute, new[] { "Title", "Name" }); context.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Index(string id) { using (var context = new CatalogueContainer()) { var model = new SiteViewModel(context, id); this.SetSeoContent(model); //if (model.Content != null && model.Layouts != null) // ViewBag.Layouts = model.Layouts; ViewBag.Categories = model.Categories; ViewBag.Projects = model.Projects; ViewBag.isHomePage = model.IsHomePage; ViewBag.MainMenu = model.Menu; if (model.IsHomePage) ViewBag.MainPage = true; return View(model); } }
public ActionResult Edit(int id, FormCollection form) { try { using (var context = new CatalogueContainer()) { var article = context.Article.First(a => a.Id == id); TryUpdateModel(article, new[] { "Title", "Date" }); article.Text = HttpUtility.HtmlDecode(form["Text"]); context.SaveChanges(); return RedirectToAction("Index", "Articles", new { area = "" }); } } catch { return View(); } }
public ActionResult Index(string category, string filter, string brand) { using (var context = new CatalogueContainer()) { var model = new CatalogueViewModel(context, category, filter, brand); //if (!model.Category.MainPage) // ViewBag.CategoryName = model.Category.Name; //model.SetFilters(); //model.ApplyFilers(); //model.ApplyPaging(); //ViewBag.Page = page ?? 0; ViewBag.MainMenu = model.Menu; ViewBag.Categories = model.Categories; ViewBag.Projects = model.Projects; ViewBag.CataloguePage = true; this.SetSeoContent(model); return View(model); } }
public ActionResult Create(FormCollection form) { try { using (var context = new CatalogueContainer()) { var attribute = new CategoryAttribute(); TryUpdateModel(attribute, new[] { "Title", "Name" }); context.AddToCategoryAttribute(attribute); context.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult AddImage(IEnumerable<HttpPostedFileBase> fileUpload) { using (var context = new CatalogueContainer()) { foreach (var file in fileUpload) { if (file != null) { string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName); string filePath = Server.MapPath("~/Content/Images"); filePath = Path.Combine(filePath, fileName); file.SaveAs(filePath); var mpi = new MainPageImage() {ImageSource = fileName}; context.AddToMainPageImage(mpi); context.SaveChanges(); } } return RedirectToAction("Index", "Home", new {area = ""}); } }
public ProjectViewModel(CatalogueContainer context, string project) : base(context, null) { Title = "Проекты"; foreach (var p in Projects.Where(p=>p.Name==project)) { p.Current = true; } if (!string.IsNullOrEmpty(project)) { Project = context.Project.Include("ProjectImages").First(c => c.Name == project); Title += " - " + Project.Title; SeoDescription = Project.SeoDescription; SeoKeywords = Project.SeoKeywords; } }
public ActionResult Edit(int id, FormCollection form) { try { using (var context = new CatalogueContainer()) { var content = context.Content.First(c => c.Id == id); TryUpdateModel(content, new[] {"Title","DescriptionTitle","SeoDescription","SeoKeywords","SortOrder"}); content.Text = HttpUtility.HtmlDecode(form["Text"]); content.Description = HttpUtility.HtmlDecode(form["Description"]); context.SaveChanges(); if(content.MainPage) return RedirectToAction("Index", "Home", new { area = "", id = "" }); return RedirectToAction("Index", "Home", new {area="", id = content.Name}); } } catch { return View(); } }
public ArticlesViewModel(CatalogueContainer context) : base(context, null) { Title = "Новости"; Articles = context.Article.ToList(); }
public ActionResult DeleteImage(int id) { using (var context = new CatalogueContainer()) { var image = context.MainPageImage.First(i => i.Id == id); ImageHelper.DeleteImage(image.ImageSource); context.DeleteObject(image); context.SaveChanges(); return RedirectToAction("Index", "Content", new { area = "Admin",id="" }); } }
public ActionResult Edit(int id) { using (var context = new CatalogueContainer()) { var category = context.Category.Include("CategoryAttributes").First(c => c.Id == id); var attributes = context.CategoryAttribute.ToList(); ViewBag.Attributes = attributes; return View(category); } }