public ActionResult Create() { try { var identity = (LoginIdentity)Thread.CurrentPrincipal.Identity; var serializer = new JavaScriptSerializer() { MaxJsonLength = int.MaxValue }; ViewBag.ItemWithCodeList = serializer.Serialize(_rawSqlService.GetBranchwiseProductCodeStockAll(identity.CompanyId, identity.BranchId)); ViewBag.ItemList = serializer.Serialize(_rawSqlService.GetBranchwiseProductStockAll(identity.CompanyId, identity.BranchId)); SuperShopPurchaseViewModel vm = new SuperShopPurchaseViewModel { Id = _purchaseService.GenerateAutoId(identity.CompanyId, identity.BranchId, "Purchase"), PurchaseDate = DateTime.Now, PurchaseDetails = new List <SuperShopPurchaseDetailViewModel>() }; vm.PurchaseDetails.Add(new SuperShopPurchaseDetailViewModel()); vm.CompanyId = identity.CompanyId; vm.BranchId = identity.BranchId; return(View(vm)); } catch (Exception ex) { return(JavaScript($"ShowResult('{ex.Message}','failure')")); } }