public ActionResult Create([Bind(Include = "ProductId,SCC,Quantity")] ProductSCCCodes productscccodes) { if (ModelState.IsValid) { if (!String.IsNullOrEmpty(productscccodes.SCC)) { productscccodes.SCC = productscccodes.SCC.Trim(); } _productServices.AddProductSccCodes(productscccodes, CurrentTenantId, CurrentUserId); return(RedirectToAction("Create", new { id = productscccodes.ProductId })); } ProductMaster productmaster = _productServices.GetProductMasterById(productscccodes.ProductId); if (productmaster == null) { return(HttpNotFound()); } ViewBag.SCC = productmaster.ProductSCCCodes.Where(m => m.IsDeleted != true); return(View(productscccodes)); }
public ProductSCCCodes SaveSccCode(ProductSCCCodes model, int productId, int userId, int tenantId) { if (model.ProductSCCCodeId == 0) { model.CreatedBy = userId; model.DateCreated = DateTime.UtcNow; model.ProductId = productId; model.TenantId = tenantId; _currentDbContext.ProductSCCCodes.Add(model); } else { model.UpdatedBy = userId; model.DateUpdated = DateTime.UtcNow; _currentDbContext.ProductSCCCodes.Attach(model); var entry = _currentDbContext.Entry(model); entry.Property(e => e.SCC).IsModified = true; entry.Property(e => e.Quantity).IsModified = true; } _currentDbContext.SaveChanges(); return(model); }