public void CallRedistributeQuantity(IList <string> styleIdList) { var settings = new SettingsService(_dbFactory); var quantityManager = new QuantityManager(_log, _time); var qtyDistributionService = new QuantityDistributionService(_dbFactory, quantityManager, _log, _time, QuantityDistributionHelper.GetDistributionMarkets(), DistributeMode.None); using (var db = _dbFactory.GetRWDb()) { db.DisableValidation(); if (!styleIdList.Any()) { qtyDistributionService.Redistribute(db); } else { var style = db.Styles.GetAllActiveAsDto().Where(st => styleIdList.Contains(st.StyleID)).ToList(); var styleIds = style.Select(st => st.Id).ToList(); qtyDistributionService.RedistributeForStyle(db, styleIds); } } }
public virtual JsonResult Redistribute(long styleId) { LogI("Redistribute, styleId=" + styleId); try { var quantityManager = new QuantityManager(LogService, Time); var service = new QuantityDistributionService(DbFactory, quantityManager, LogService, Time, QuantityDistributionHelper.GetDistributionMarkets(), DistributeMode.None); var listings = service.RedistributeForStyle(Db, styleId); return(new JsonResult() { Data = ValueResult <IList <ListingQuantityDTO> > .Success("Quantity was redistributed", listings), JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception ex) { LogE("Redistribute, styleId=" + styleId, ex); return(new JsonResult() { Data = MessageResult.Error(ex.Message), JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }