public IActionResult Edit(int id, CategorySkuViewModel model) { if (ModelState.IsValid) { _categorySkuRepository.Edit(id, model); return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult Create(CategorySkuViewModel model) { if (ModelState.IsValid) { _categorySkuRepository.Create(model); return(RedirectToAction("Index")); } return(View(model)); }
public void Edit(int id, CategorySkuViewModel model) { var _categorySku = _appDbContext.CategerySkus .FirstOrDefault(c => c.CategorySkuId == id); _categorySku.Name = model.Name; _categorySku.ImgThambnail = model.ImgThambnail; _appDbContext.SaveChanges(); }
public CategorySkuViewModel Get(int id) { var _categorySku = _appDbContext.CategerySkus .FirstOrDefault(c => c.CategorySkuId == id); var _model = new CategorySkuViewModel { Name = _categorySku.Name }; return(_model); }
public void Create(CategorySkuViewModel model) { if (model.ImgThambnail == null) { model.ImgThambnail = @"/images/CategorySku/default.png"; } var _categorySku = new CategorySku { Name = model.Name, ImgThambnail = model.ImgThambnail }; _appDbContext.CategerySkus.Add(_categorySku); _appDbContext.SaveChanges(); }