public virtual ActionResult Submit(StyleViewModel model, int?generateForMarket) { var openUrl = String.Empty; LogI("Submit, model=" + model + ", generateForMarket=" + generateForMarket); //Save if (ModelState.IsValid) { var messages = new List <MessageString>(); var errors = StyleViewModel.Validate(Db, model.StyleId, model.Id, model.StyleItems.Items); if (!errors.Any()) { //Save changes model.SetUploadedImages(SessionHelper.GetUploadedImages()); //Generate Excel //NOTE: before apply, setting auto-generated barcodes if (generateForMarket == (int)MarketType.Amazon) { openUrl = model.GenerateUS(Db, BarcodeService, AmazonCategoryService, Time.GetAppNowTime(), out messages); } if (generateForMarket == (int)MarketType.AmazonEU) { openUrl = model.GenerateUK(Db, BarcodeService, AmazonCategoryService, Time.GetAppNowTime(), out messages); } if (generateForMarket == (int)MarketType.AmazonAU) { openUrl = "";// model.GenerateUK(Db, BarcodeService, Time.GetAppNowTime(), out messages); } if (generateForMarket == (int)MarketType.Walmart) { openUrl = model.GenerateWalmart(Db, BarcodeService, Time.GetAppNowTime(), out messages); } var applyItemQty = generateForMarket != null && generateForMarket != (int)MarketType.None; //NOTE: only when generate model.Apply(Db, LogService, Cache, QuantityManager, PriceManager, BarcodeService, ActionService, StyleHistoryService, AutoCreateListingService, applyItemQty, DateHelper.GetAppNowTime(), AccessManager.UserId); SessionHelper.ClearUploadedImages(); } if (messages.Any() || errors.Any()) { errors.AddRange(messages); errors.ForEach(e => ModelState.AddModelError(e.Key ?? "model", e.Message)); model.ReInitFeatures(Db); return(PartialView(PopupContentView, model)); } else { //Get Lite Version of updates for Grid model = StyleViewModel.GetAll(Db, new StyleSearchFilterViewModel() { StyleId = model.Id }).Items?.FirstOrDefault(); //TODO: Add "Status", now only updates StatusCode return(Json(new UpdateRowViewModel(model, "Styles", new[] { "HasImage", "Image", "Thumbnail", "StyleId", "DropShipperName", "Name", "StyleItemCaches", "StyleItems", "Locations", "MainLocation", "HasLocation", "IsOnline", "OnHold", "CreateDate", "IsHidden", "ToPhotographer" }, false, openUrl))); } } ViewBag.IsAdd = false; return(PartialView(PopupContentView, model)); }