コード例 #1
0
        public virtual ActionResult GetIdListByFilters(string barcode,
                                                       int?gender,
                                                       [Bind(Prefix = "itemStyles[]")] List <int> itemStyles,
                                                       [Bind(Prefix = "sleeves[]")] List <int> sleeves,
                                                       int?mainLicense,
                                                       int?subLicense,
                                                       int?holiday,
                                                       bool hasInitialQty)
        {
            LogI("GetFilteredIdList, barcode=" + barcode
                 + ", gender=" + gender
                 + ", itemStyles=" + itemStyles
                 + ", sleeves=" + sleeves
                 + ", mainLicense=" + mainLicense
                 + ", subLicense=" + subLicense
                 + ", hasInitialQty=" + hasInitialQty);
            var searchFilter = new StyleSearchFilterViewModel()
            {
                Barcode       = StringHelper.TrimWhitespace(barcode),
                Gender        = gender,
                ItemStyles    = itemStyles,
                Sleeves       = sleeves,
                HolidayId     = holiday,
                MainLicense   = mainLicense,
                SubLicense    = subLicense,
                HasInitialQty = hasInitialQty
            };
            var idList = StyleViewModel.GetIdListByFilters(Db, searchFilter);

            return(Json(ValueResult <IEnumerable <long> > .Success("", idList), JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public virtual ActionResult GetAll(GridRequest request)
        {
            LogI("GetAll");

            var searchFilter = new StyleSearchFilterViewModel();
            var items        = StyleLiteCountingViewModel.GetAll(Db, searchFilter).ToList();
            var data         = new GridResponse <StyleLiteCountingViewModel>(items, items.Count, Time.GetAppNowTime());

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public virtual ActionResult GetAllUpdates(DateTime?fromDate)
        {
            LogI("GetAllUpdates, fromDate=" + fromDate);

            var searchFilter = new StyleSearchFilterViewModel()
            {
                FromReSaveDate = fromDate
            };
            var items = StyleCountingViewModel.GetAll(Db, searchFilter).ToList();
            var data  = new GridResponse <StyleCountingViewModel>(items, items.Count, Time.GetAppNowTime());

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        public static IList <StyleDescriptionViewModel> GetAll(IUnitOfWork db,
                                                               StyleSearchFilterViewModel filter)
        {
            IQueryable <StyleEntireDto> styleQuery = from st in db.Styles.GetAllActiveAsDtoEx()
                                                     orderby st.Id descending
                                                     select st;

            if (filter.StyleId.HasValue)
            {
                styleQuery = styleQuery.Where(s => s.Id == filter.StyleId.Value);
            }

            if (filter.FromReSaveDate.HasValue)
            {
                styleQuery = styleQuery.Where(s => s.ReSaveDate >= filter.FromReSaveDate.Value);
            }

            var styleList = styleQuery.Select(s => new StyleDescriptionViewModel
            {
                Id          = s.Id,
                StyleString = s.StyleID,

                Image = s.Image,

                Name = s.Name,

                Description  = s.Description,
                SearchTerms  = s.SearchTerms,
                BulletPoint1 = s.BulletPoint1,
                BulletPoint2 = s.BulletPoint2,
                BulletPoint3 = s.BulletPoint3,
                BulletPoint4 = s.BulletPoint4,
                BulletPoint5 = s.BulletPoint5,

                CreateDate = s.CreateDate,
                UpdateDate = s.UpdateDate,
                ReSaveDate = s.ReSaveDate,
            }).ToList();

            //NOTE: fast exist for case with ReSaveDate, in most cases count will be = 0
            if (styleList.Count == 0)
            {
                return(new List <StyleDescriptionViewModel>());
            }

            var allFeatures = db.StyleFeatureValues.GetFeatureValueForAllStyleByFeatureId(new int[]
            {
                StyleFeatureHelper.ITEMSTYLE,
                StyleFeatureHelper.MAIN_LICENSE,
                StyleFeatureHelper.SUB_LICENSE1
            });

            var styleItemList = (from si in db.StyleItems.GetAll()
                                 join st in styleQuery on si.StyleId equals st.Id into withStyle
                                 from st in withStyle.DefaultIfEmpty()
                                 join sic in db.StyleItemCaches.GetAll() on si.Id equals sic.Id into withCache
                                 from sic in withCache.DefaultIfEmpty()
                                 select new StyleItemShowViewModel()
            {
                StyleId = si.StyleId,

                RemainingQuantity = sic.RemainingQuantity
            }).ToList();


            styleList.ForEach(i =>
            {
                i.Image             = GetImage(i.Image);
                i.RemainingQuantity = styleItemList.Where(si => si.StyleId == i.Id).Sum(si => si.RemainingQuantity ?? 0);
                i.MainLicense       = allFeatures.FirstOrDefault(f => f.StyleId == i.Id && f.FeatureId == StyleFeatureHelper.MAIN_LICENSE)?.Value;
                i.SubLicense        = allFeatures.FirstOrDefault(f => f.StyleId == i.Id && f.FeatureId == StyleFeatureHelper.SUB_LICENSE1)?.Value;
                i.ItemStyle         = allFeatures.FirstOrDefault(f => f.StyleId == i.Id && f.FeatureId == StyleFeatureHelper.ITEMSTYLE)?.Value;
            });
            return(styleList);
        }
コード例 #6
0
        public static IList <StyleLiteCountingViewModel> GetAll(IUnitOfWork db,
                                                                StyleSearchFilterViewModel filter)
        {
            IQueryable <Style> styleQuery = from st in db.Styles.GetAll()
                                            orderby st.Id descending
                                            select st;

            if (filter.StyleId.HasValue)
            {
                styleQuery = styleQuery.Where(s => s.Id == filter.StyleId.Value);
            }

            if (filter.FromReSaveDate.HasValue)
            {
                styleQuery = styleQuery.Where(s => s.ReSaveDate >= filter.FromReSaveDate.Value);
            }

            var styleList = styleQuery.Select(s => new StyleLiteCountingViewModel
            {
                Id      = s.Id,
                StyleId = s.StyleID,

                Image = s.Image,

                Name = s.Name,

                //CountingStatus = s.LiteCountingStatus,
                //CountingName = s.LiteCountingName,

                CreateDate = s.CreateDate,
                UpdateDate = s.UpdateDate,
                ReSaveDate = s.ReSaveDate,
            }).ToList();

            //NOTE: fast exist for case with ReSaveDate, in most cases count will be = 0
            if (styleList.Count == 0)
            {
                return(new List <StyleLiteCountingViewModel>());
            }

            //Style Items
            var styleItemList = (from si in db.StyleItems.GetAll()
                                 join st in styleQuery on si.StyleId equals st.Id
                                 join sic in db.StyleItemCaches.GetAll() on si.Id equals sic.Id into withCache
                                 from sic in withCache.DefaultIfEmpty()
                                 select new StyleItemCountingViewModel()
            {
                Id = si.Id,
                Size = si.Size,
                Color = si.Color,

                RemainingQuantity = sic.RemainingQuantity,

                CountingDate = si.LiteCountingDate,
                CountingName = si.LiteCountingName,
                CountingStatus = si.LiteCountingStatus,

                ApproveStatus = si.ApproveStatus,

                StyleId = si.StyleId,
            }).ToList();

            foreach (var style in styleList)
            {
                style.StyleItems = styleItemList.Where(si => si.StyleId == style.Id)
                                   .OrderBy(si => SizeHelper.GetSizeIndex(si.Size))
                                   .ToList();
            }

            //Style Boxes
            List <StyleBoxItemViewModel> openBoxList = new List <StyleBoxItemViewModel>();

            if (styleList.Count < 10)
            {
                openBoxList = (from b in db.OpenBoxCountings.GetAll()
                               join bi in db.OpenBoxCountingItems.GetAll() on b.Id equals bi.BoxId
                               join st in styleQuery on b.StyleId equals st.Id
                               select new StyleBoxItemViewModel
                {
                    StyleId = b.StyleId,
                    BoxQuantity = b.BoxQuantity,
                    StyleItemId = bi.StyleItemId,
                    Quantity = bi.Quantity,
                }).ToList();
            }
            else
            {
                openBoxList = (from b in db.OpenBoxCountings.GetAll()
                               join bi in db.OpenBoxCountingItems.GetAll() on b.Id equals bi.BoxId
                               select new StyleBoxItemViewModel
                {
                    StyleId = b.StyleId,
                    BoxQuantity = b.BoxQuantity,
                    StyleItemId = bi.StyleItemId,
                    Quantity = bi.Quantity,
                }).ToList();
            }

            List <StyleBoxItemViewModel> sealedBoxList = new List <StyleBoxItemViewModel>();

            if (styleList.Count < 10)
            {
                sealedBoxList = (from b in db.SealedBoxCountings.GetAll()
                                 join bi in db.SealedBoxCountingItems.GetAll() on b.Id equals bi.BoxId
                                 join st in styleQuery on b.StyleId equals st.Id
                                 select new StyleBoxItemViewModel
                {
                    StyleId = b.StyleId,
                    BoxQuantity = b.BoxQuantity,
                    StyleItemId = bi.StyleItemId,
                    Quantity = bi.BreakDown,
                }).ToList();
            }
            else
            {
                sealedBoxList = (from b in db.SealedBoxCountings.GetAll()
                                 join bi in db.SealedBoxCountingItems.GetAll() on b.Id equals bi.BoxId
                                 select new StyleBoxItemViewModel
                {
                    StyleId = b.StyleId,
                    BoxQuantity = b.BoxQuantity,
                    StyleItemId = bi.StyleItemId,
                    Quantity = bi.BreakDown,
                }).ToList();
            }

            //Style Locations
            var styleLocations = (from l in db.StyleLocations.GetAllAsDTO()
                                  join st in styleQuery on l.StyleId equals st.Id
                                  orderby l.IsDefault descending
                                  select l).ToList();

            styleList.ForEach(i =>
            {
                i.OpenBoxes   = openBoxList.Where(b => b.StyleId == i.Id).ToList();
                i.SealedBoxes = sealedBoxList.Where(b => b.StyleId == i.Id).ToList();
                i.Image       = GetImage(i.Image);
                i.Locations   = styleLocations.Where(s => s.StyleId == i.Id).Select(s => new LocationViewModel(s)).ToList();
            });

            foreach (var style in styleList)
            {
                foreach (var styleItem in style.StyleItems)
                {
                    styleItem.BoxQuantity = style.OpenBoxes.Where(b => b.StyleItemId == styleItem.Id).Sum(b => b.BoxQuantity * b.Quantity)
                                            + style.SealedBoxes.Where(b => b.StyleItemId == styleItem.Id).Sum(b => b.BoxQuantity * b.Quantity);
                }
            }

            if (filter.IsApproveMode)
            {
                styleList = styleList.Where(st => Math.Abs(st.TotalQuantity - st.TotalRemaining) > 10).ToList();
            }


            return(styleList);
        }
コード例 #7
0
        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));
        }