public void DeleteProduct(long id) { WSProduct result = GetProduct(id); result.Status = false; UpdateProduct(result); }
public WSProduct GetProduct(long id) { WSProduct result = _dbContext.Products.Include(p => p.Materials) .ThenInclude(pm => pm.WSMaterial) .Where(p => p.Id == id && p.Status == true).FirstOrDefault(); return(result); }
public IActionResult Create(WSProduct model) { if (ModelState.IsValid) { _workshopRepository.AddProduct(model); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public IActionResult Edit(WSProduct model) { if (ModelState.IsValid) { _workshopRepository.UpdateProduct(model); return(RedirectToAction(nameof(Index))); } WSProduct temp = _workshopRepository.GetProduct(model.Id); temp.ProductName = model.ProductName; temp.Version = model.Version; return(View(temp)); }
public void UpdateProduct(WSProduct model) { _dbContext.Products.Update(model); _dbContext.SaveChanges(); }
public void AddProduct(WSProduct model) { _dbContext.Products.Add(model); _dbContext.SaveChanges(); }
public IActionResult Edit(long id) { WSProduct model = _workshopRepository.GetProduct(id); return(View(model)); }