I want to update at the condition if record is already exist in database in asp.net mvc. here is my code. it is not working : I want to update the condition if the record already exists in database in asp.net MVC. here is my code. it is not working.
 Here my code it is not working. 

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult ProductDiscount(ProductDiscount productDiscount)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new ViewModelProductDiscount()
                {
                    Products = _context.Products.ToList()
                };
                return View(viewModel);
            }
            var id = productDiscount.ProductId;
            var disInDb = _context.ProductDiscounts.FirstOrDefault(p => p.ProductId == id);
            if (disInDb==null)
            {
                _context.ProductDiscounts.Add(productDiscount);
                _context.SaveChanges();              
            }
            else
            {
                _context.ProductDiscounts.Add(disInDb);
                _context.SaveChanges();
                return Content(disInDb.Id.ToString());
            }
            

           return RedirectToAction("Products");
        }