public ActionResult CreateItem(ItemMaster item) { List <string> res = new List <string>(); ItemMaster _ItemMaster = new ItemMaster(); try { if (ModelState.IsValid) { var currentuser = Commonhelper.GetCurrentUserDetails(); _ItemMaster.StoreId = currentuser.StoreId; _ItemMaster.CompanyId = currentuser.CompanyId; _ItemMaster.Description = item.Description; _ItemMaster.ProductCode = item.ProductCode; _ItemMaster.BarCode = item.BarCode; _ItemMaster.SkuCode = item.SkuCode; _ItemMaster.SapCode = item.SapCode; _ItemMaster.Category = item.Category; _ItemMaster.Color = item.Color; _ItemMaster.SubCategory = item.SubCategory; _ItemMaster.ProductName = item.ProductName; _ItemMaster.Brand = item.Brand; _ItemMaster.Size = item.Size; _ItemMaster.Quality = item.Quality; _ItemMaster.Gst = item.Gst; _ItemMaster.Reorderlevel = item.Reorderlevel; _ItemMaster.Mrp = item.Mrp; _ItemMaster.Costprice = item.Costprice; _ItemMaster.Sellprice = item.Sellprice; _ItemMaster.offer = item.offer; _ItemMaster.FinancialYear = item.FinancialYear; _ItemMaster.workstation = Commonhelper.GetStation(); _ItemMaster.HsnCode = item.HsnCode; _ItemMaster.MaximumQuantity = item.MaximumQuantity; _ItemMaster.MinimumQuantity = item.MinimumQuantity; _ItemMaster.BoxQuantity = item.BoxQuantity; _ItemMaster.IsUnique = item.IsUnique; _ItemMaster.Mou = item.Mou; _ItemMaster.SubMou = item.SubMou; _ItemMaster.ItemOrder = item.ItemOrder; _ItemMaster.CreatedDate = DateTime.Now; _ItemMaster.CreatedBy = currentuser.Id; _ItemMaster.Isactive = true; if (item.ItemOptionalDetails.Count() > 0) { foreach (var _item in item.ItemOptionalDetails) { ItemOptionalDetails option = new ItemOptionalDetails(); option.Id = Guid.NewGuid().ToString(); option.ItemId = _ItemMaster.Id; option.OptionalId = _item.OptionalId; option.OptionalValue = _item.OptionalValue; _ItemMaster.ItemOptionalDetails.Add(option); } } Commonhelper.SaveItem(_ItemMaster); return(Content("<script language='javascript' type='text/javascript'>alert('Item Created successfully!');</script>")); } else { return(View()); } } catch (Exception ex) { } return(View()); }