public async Task <IActionResult> Edit(long id, [Bind("Name,Slug,Description,ParentCategoryId,Id,CreateDate,CreatedBy,UpdateDate,UpdatedBy,AppTenantId")] GalleryItemCategory galleryItemCategory) { if (id != galleryItemCategory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { galleryItemCategory.UpdatedBy = User.Identity.Name ?? "username"; galleryItemCategory.UpdateDate = DateTime.Now; galleryItemCategory.AppTenantId = tenant.AppTenantId; _context.Update(galleryItemCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GalleryItemCategoryExists(galleryItemCategory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["ParentCategoryId"] = new SelectList(_context.GalleryItemCategories.ToList(), "Id", "Name", galleryItemCategory.ParentCategoryId); return(View(galleryItemCategory)); }
static void recurseGalleryItem(ref List <GalleryItemCategory> cl, GalleryItemCategory start, int level, ref string result) { foreach (GalleryItemCategory child in cl) { if (child.ParentCategory == start) { result += "<option value='" + child.Id.ToString() + "'>" + (new String(' ', level * 2)).Replace(" ", " ") + child.Name + "</option>"; recurseGalleryItem(ref cl, child, level + 1, ref result); } } }
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 async Task <IActionResult> Create([Bind("Name,Slug,Description,ParentCategoryId,Id,CreateDate,CreatedBy,UpdateDate,UpdatedBy,AppTenantId")] GalleryItemCategory galleryItemCategory) { if (ModelState.IsValid) { galleryItemCategory.CreatedBy = User.Identity.Name ?? "username"; galleryItemCategory.CreateDate = DateTime.Now; galleryItemCategory.UpdatedBy = User.Identity.Name ?? "username"; galleryItemCategory.UpdateDate = DateTime.Now; galleryItemCategory.AppTenantId = tenant.AppTenantId; _context.Add(galleryItemCategory); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["ParentCategoryId"] = new SelectList(_context.GalleryItemCategories.ToList(), "Id", "Id", galleryItemCategory.ParentCategoryId); return(View(galleryItemCategory)); }
// GET: CmsCore/GalleryItemCategories/Create public IActionResult Create() { var galleryItemCategory = new GalleryItemCategory(); var parentCategory = _context.GalleryItemCategories.ToList(); var result = ""; recurseGalleryItem(ref parentCategory, null, 0, ref result); ViewBag.ParentCategory = result; galleryItemCategory.CreatedBy = User.Identity.Name ?? "username"; galleryItemCategory.CreateDate = DateTime.Now; galleryItemCategory.UpdatedBy = User.Identity.Name ?? "username"; galleryItemCategory.UpdateDate = DateTime.Now; galleryItemCategory.AppTenantId = tenant.AppTenantId; return(View(galleryItemCategory)); }
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)); }
public void UpdateGalleryItemCategory(GalleryItemCategory galleryItemCategory) { galleryItemCategoryRepository.Update(galleryItemCategory); }
public void CreateGalleryItemCategory(GalleryItemCategory galleryItemCategory) { galleryItemCategoryRepository.Add(galleryItemCategory); }