public static ValidationResult[] Validate(IUnitOfWork db, SizeMappingViewModel item)
        {
            var exists = db.SizeMappings.GetExists(item.StyleSize, item.ItemSize);

            if (exists.Any(s => s.Id != item.Id)) //Exclude current
            {
                return new[] { new ValidationResult("This combination already exist"), }
            }
            ;
            return(new ValidationResult[] {});
        }
        public static SizeMappingViewModel Add(IUnitOfWork db, SizeMappingViewModel item, DateTime when, long?by)
        {
            var sizeMapping = new SizeMapping
            {
                StyleSize  = item.StyleSize,
                ItemSize   = item.ItemSize,
                Priority   = item.Priority,
                CreateDate = when,
                CreatedBy  = by
            };

            db.SizeMappings.Add(sizeMapping);
            db.Commit();


            item.Id = sizeMapping.Id;
            return(item);
        }
        public static SizeMappingViewModel Update(IUnitOfWork db, SizeMappingViewModel item, DateTime when, long?by)
        {
            if (item.Id.HasValue)
            {
                var sizeMapping = db.SizeMappings.Get(item.Id.Value);

                if (sizeMapping != null)
                {
                    sizeMapping.StyleSize = item.StyleSize;
                    sizeMapping.ItemSize  = item.ItemSize;
                    sizeMapping.Priority  = item.Priority;

                    sizeMapping.UpdateDate = when;
                    sizeMapping.UpdatedBy  = by;
                    db.Commit();

                    return(item);
                }
            }
            return(null);
        }