public ActionResult Create([Bind(Include = "Id,BarcodeNumber,Name,PurchasePrice,SellingPrice,MadeInCountry,ProductionDate,ExpiryDate,HasGuarantee,CategoryId,SupplierId,CreatedDate,CreatedBy,UpdatedDate,UpdatedBy,IsArchived,Quentity")] Product product) { if (ModelState.IsValid) { var maybe = _productManger.GetAllBind().Where(c => c.CategoryId == product.CategoryId && c.IsArchived == false); if (maybe.FirstOrDefault() == null) { Category category = _categoryManger.GetBy(product.CategoryId); category.HiddInMenu = false; _categoryManger.Save(); } product.CreatedDate = DateTime.Now; product.UpdatedDate = DateTime.Now; product.CreatedBy = HttpContext.Request.UserHostAddress + "/" + User.Identity.Name + "/" + Request.LogonUserIdentity.Name; product.UpdatedBy = HttpContext.Request.UserHostAddress + "/" + User.Identity.Name + "/" + Request.LogonUserIdentity.Name; setCategoryAndSupplierlist(); _productManger.Add(product); return(RedirectToAction("Index")); } return(View(product)); }