public ActionResult Create() { var galitemcvm = new GalleryItemCategoryViewModel(); ViewBag.GalleryItemCategories = new SelectList(galleryItemCategoryService.GetGalleryItemCategories(), "Id", "Name"); return(View(galitemcvm)); }
public ActionResult Edit(GalleryItemCategoryViewModel galCVM) { if (ModelState.IsValid) { GalleryItemCategory pc = galleryItemCategoryService.GetGalleryItemCategory(galCVM.Id); pc.Name = galCVM.Name; pc.Slug = galCVM.Slug; pc.Description = galCVM.Description; pc.ParentCategoryId = galCVM.ParentCategoryId; galleryItemCategoryService.UpdateGalleryItemCategory(pc); galleryItemCategoryService.SaveGalleryItemCategory(); return(RedirectToAction("Index")); } ViewBag.LinkCategories = new SelectList(galleryItemCategoryService.GetGalleryItemCategories().Where(c => c.Id != galCVM.Id), "Id", "Name", galCVM.ParentCategoryId); return(View(galCVM)); }
public ActionResult Edit(long id) { var galitem = galleryItemCategoryService.GetGalleryItemCategory(id); if (galitem != null) { GalleryItemCategoryViewModel linkCVM = new GalleryItemCategoryViewModel(); linkCVM.Id = galitem.Id; linkCVM.Name = galitem.Name; linkCVM.Slug = galitem.Slug; linkCVM.Description = galitem.Description; linkCVM.ParentCategoryId = galitem.ParentCategoryId; ViewBag.GalleryItemCategories = new SelectList(galleryItemCategoryService.GetGalleryItemCategories().Where(c => c.Id != id), "Id", "Name", galitem.ParentCategoryId); return(View(linkCVM)); } return(RedirectToAction("Index")); }
public ActionResult Create(GalleryItemCategoryViewModel vm) { if (ModelState.IsValid) { GalleryItemCategory galitem = new GalleryItemCategory(); galitem.Name = vm.Name; galitem.ParentCategoryId = vm.ParentCategoryId; galitem.Description = vm.Description; galitem.Slug = vm.Slug; galitem.AddedBy = User.Identity.Name ?? "username"; galitem.AddedDate = DateTime.Now; galitem.ModifiedBy = User.Identity.Name ?? "username"; galitem.ModifiedDate = DateTime.Now; galleryItemCategoryService.CreateGalleryItemCategory(galitem); galleryItemCategoryService.SaveGalleryItemCategory(); return(RedirectToAction("Index")); } return(View(vm)); }