public IActionResult Update(int id) { var model = new UISubCategoryListCategory(); model.SubCategory = repository.GetByColumName("Id", id).FirstOrDefault(); var c = new CategoryRepository().GetAll("Id", "Name"); if (c.Count > 0) { foreach (var item in c) { model.Categores.Add(new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem(item.Name, item.Id.ToString())); } } return(View("AddOrUpdate", model)); }
public bool ChangeSubCategory(int id, int categoryId, bool value) { var subCategory = new SubCategoryRepository(); var s = subCategory.GetByColumName("Id", id).FirstOrDefault(); if (s == null) { return(false); } if (value) { s.CategoryId = categoryId; } else { s.CategoryId = 0; } return(subCategory.Update(s, id)); }