public async Task <IActionResult> Edit(int id, ShadeColors shadeColors) { if (id != shadeColors.Id) { return(NotFound()); } if (shadeColors != null) { _db.ShadeColors.Update(shadeColors); await _db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(nameof(Index))); }
public async Task <IActionResult> Create(ShadeColors shadeColors) { if (ModelState.IsValid) { var shadeColor = _db.ShadeColors.Where(x => x.Name == shadeColors.Name).FirstOrDefault(); if (shadeColor != null) { return(View(shadeColors)); } else { _db.ShadeColors.Add(shadeColors); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View(shadeColors)); }