public virtual ActionResult Submit(StyleReferencesViewModel model) { LogI("Submit, model=" + model); //Save if (ModelState.IsValid) { var errors = model.Validate(Db); StyleViewModel returnModel = null; if (!errors.Any()) { model.SetUploadedImages(SessionHelper.GetUploadedImages()); var id = model.Apply(Db, Cache, Time.GetAppNowTime(), AccessManager.UserId); returnModel = StyleViewModel.GetAll(Db, new StyleSearchFilterViewModel() { StyleId = id }).Items?.FirstOrDefault(); SessionHelper.ClearUploadedImages(); } else { foreach (var error in errors) { ModelState.AddModelError("", error.ErrorMessage); } return(PartialView(PopupContentView, model)); } return(Json(new UpdateRowViewModel(returnModel, "Styles", new[] { "HasImage", "Image", "Thumbnail", "StyleId", "Name", "StyleItemCaches", "StyleItems", "Locations", "MainLocation", "HasLocation", "IsOnline", "OnHold", "CreateDate" }, false))); } return(View(PopupContentView, model)); }
public virtual ActionResult Submit(StylePriceViewModel model) { LogI("Submit, model=" + model); //Save if (ModelState.IsValid) { var styleItemHistory = new StyleItemHistoryService(LogService, Time, DbFactory); model.Apply(Db, DbFactory, LogService, Cache, PriceManager, styleItemHistory, ActionService, Time.GetAppNowTime(), AccessManager.UserId); var outputModel = StyleViewModel.GetAll(Db, new StyleSearchFilterViewModel() { StyleId = model.StyleId }).Items?.FirstOrDefault(); return(Json(new UpdateRowViewModel(outputModel, "Styles", new[] { "UsedBoxQuantity", "HasManuallyQuantity", "ManuallyQuantity", "RemainingQuantity", "TotalQuantity", "BoxQuantity", "InventoryQuantity", "MarketsSoldQuantity", "ScannedSoldQuantity", "SentToFBAQuantity", "SpecialCaseQuantity", "TotalMarketsSoldQuantity", "TotalScannedSoldQuantity", "TotalSentToFBAQuantity", "TotalSpecialCaseQuantity", "QuantityModeName", "StyleItemCaches", }, false))); } return(View(PopupContentView, model)); }
public virtual ActionResult GetAllUpdates(DateTime?fromDate) { LogI("GetAllUpdates, fromDate=" + fromDate); IList <StyleViewModel> items = new List <StyleViewModel>(); DateTime?when = null; if (fromDate.HasValue) { var searchFilter = new StyleSearchFilterViewModel() { FromReSaveDate = fromDate }; items = StyleViewModel.GetAll(Db, searchFilter).Items.ToList(); when = Time.GetAppNowTime(); } var data = new GridResponse <StyleViewModel>(items, items.Count, when); return(Json(data, JsonRequestBehavior.AllowGet)); }
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)); }
public virtual ActionResult GetAll(GridRequest request, string styleString, string keywords, long?dropShipperId, bool onlyInStock, string barcode, string gender, [Bind(Prefix = "itemStyles[]")] List <int> itemStyles, [Bind(Prefix = "sleeves[]")] List <int> sleeves, int?holidayId, int?mainLicense, int?subLicense, bool hasInitialQty, int?pictureStatus, int?fillingStatus, int?noneSoldPeriod, string onlineStatus, bool includeKiosk, bool onlyOnHold, int?minQty, string excludeMarketplaceId, string includeMarketplaceId) { LogI("GetAll, barcode=" + barcode + ", keywords=" + keywords + ", styleString=" + styleString + ", dropShipperId=" + dropShipperId + ", gender=" + gender + ", itemStyles=" + itemStyles + ", sleeves=" + sleeves + ", holidayId=" + holidayId + ", pictureStatus=" + pictureStatus + ", fillingStatus=" + fillingStatus + ", noneSoldPeriod=" + noneSoldPeriod + ", onlineStatus=" + onlineStatus + ", mainLicense=" + mainLicense + ", subLicense=" + subLicense + ", onlyInStock=" + onlyInStock + ", minQty=" + minQty + ", includeKisok=" + includeKiosk + ", onlyOnHold=" + onlyOnHold + ", excludeMarketplaceId=" + excludeMarketplaceId + ", includeMarketplaceId=" + includeMarketplaceId); var genderIds = (gender ?? "").Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .Select(g => Int32.Parse(g)) .ToList(); var pageSize = request.ItemsPerPage; var searchFilter = new StyleSearchFilterViewModel() { StyleString = StringHelper.TrimWhitespace(styleString), Barcode = StringHelper.TrimWhitespace(barcode), Keywords = StringHelper.TrimWhitespace(keywords), Genders = genderIds, DropShipperId = dropShipperId, MainLicense = mainLicense, SubLicense = subLicense, ItemStyles = itemStyles, Sleeves = sleeves, HolidayId = holidayId, OnlineStatus = onlineStatus, PictureStatus = pictureStatus, FillingStatus = fillingStatus, NoneSoldPeriod = noneSoldPeriod, MinQty = minQty, ExcludeMarketplaceId = excludeMarketplaceId, IncludeMarketplaceId = includeMarketplaceId, OnlyInStock = onlyInStock, IncludeKiosk = includeKiosk, OnlyOnHold = onlyOnHold, //BrandName = StringHelper.TrimWhitespace(brand), StartIndex = (request.Page - 1) * pageSize, LimitCount = pageSize, SortField = request.SortField, SortMode = request.SortMode == "asc" ? 0 : 1, }; var gridResult = StyleViewModel.GetAll(Db, searchFilter); gridResult.RequestTimeStamp = request.TimeStamp; //var data = new GridResponse<StyleViewModel>(items, items.Count, Time.GetAppNowTime()); return(Json(gridResult, JsonRequestBehavior.AllowGet)); }