public static List<ProductInfo> GetByType1(ProjectSIAEntities db, string type1) { using (var rl = new ReadLock()) { return GetAllProductInfoList(db).Where(x => x.Type1 == type1).ToList(); } }
public static List<string> GetType2ListByType1(ProjectSIAEntities db, string type1) { using (var rl = new ReadLock()) { return GetAllProductInfoList(db).Where(x => x.Type1 == type1).Select(x => x.Type2) .Distinct().OrderBy(x => x).ToList(); } }
public static List<ProductInfo> GetAllProductInfoList(ProjectSIAEntities db, bool reload = false) { using (var rl = new ReadLock()) { if (_productInfoList == null || reload) Caching(db); return _productInfoList; } }
public static List<Order> GetOrderList(ProjectSIAEntities db, DateTime beginDate, DateTime endDate) { using (var rl = new ReadLock()) { return db.OrderInfo.Where(x => x.payDate >= beginDate && x.payDate <= endDate) .ToList() .Select(x => new Order(x)) .ToList(); //return GetAllOrderList(db).Where(x => (x.PayDate >= beginDate && x.PayDate <= endDate)).ToList(); } }
/// <summary> 매핑된 디자이너 이름 포함 검색 </summary> public static List<ProductInfo> SearchWithDesignerName(ProjectSIAEntities db, string[] keywords) { using (var rl = new ReadLock()) { var result = new List<ProductInfo>(); #region 디자이너 이름 전처리 var DesignerNameDic = DesignerMappingManager.GetAllMappingList(db) .Join(DesignerManager.GetAllDesingerList(db), x => x.DesignerId, y => y.Id, (x, y) => new { x.ProductInfoId, y.Name }) .GroupBy(x => new { x.ProductInfoId }) .Select(x => new { x.Key.ProductInfoId, DesignerNames = x.Select(e => e.Name).StringJoin(" ") }) .ToDictionary(x => x.ProductInfoId, y => y.DesignerNames); #endregion var productList = GetAllProductInfoList(db); foreach (var product in productList) { var str = product.Type1 + product.Type2 + product.Type3 + product.Name; if (DesignerNameDic.ContainsKey(product.Id)) str += DesignerNameDic[product.Id]; var allChecked = true; foreach (var keyword in keywords) { if (!str.Contains(keyword)) { allChecked = false; break; } } if (allChecked) result.Add(product); } return result; } }
public static List<string> SearchType2ByType1(ProjectSIAEntities db, string type1, string[] keywords) { using (var rl = new ReadLock()) { var type2List = GetType2ListByType1(db, type1); if (keywords.Contains(".")) return type2List; var result = new List<string>(); foreach (var type2 in type2List) { var allChecked = true; foreach (var keyword in keywords) { if (!type2.Contains(keyword)) { allChecked = false; break; } } if (allChecked) result.Add(type2); } return result; } }
public static List<ProductInfo> GetListByProductInfoId(ProjectSIAEntities db, IEnumerable<int> productInfoIdList) { using (var rl = new ReadLock()) { if (_productInfoDic == null) GetAllProductInfoList(db, true); if (productInfoIdList.Where(x => !_productInfoDic.ContainsKey(x)).Any()) throw new AutistarException("등록되지 않은 ProductInfo Id가 있습니다."); return productInfoIdList.Select(x => _productInfoDic[x]).ToList(); } }
/// <summary> 분류1,2,3 + 이름 검색 </summary> public static List<ProductInfo> Search(ProjectSIAEntities db, string[] keywords) { using (var rl = new ReadLock()) { var result = new List<ProductInfo>(); var productList = GetAllProductInfoList(db); foreach (var product in productList) { var str = product.Type1 + product.Type2 + product.Type3 + product.Name; var allChecked = true; foreach (var keyword in keywords) { if (!str.Contains(keyword)) { allChecked = false; break; } } if (allChecked) result.Add(product); } return result; } }
public static List<Member> SearchMemberByName(ProjectSIAEntities db, string keyword) { using (var rl = new ReadLock()) { return GetAllMemberList(db).Where(x => x.Name != "dummy").Where(x => x.Name.Contains(keyword)).ToList(); } }
public static ProductInfo GetByProductInfoId(ProjectSIAEntities db, int productInfoId) { using (var rl = new ReadLock()) { if (_productInfoDic == null) GetAllProductInfoList(db, true); if (!_productInfoDic.ContainsKey(productInfoId)) throw new AutistarException("등록되지 않은 상품 기본정보 일련번호입니다. (id: {0})".With(productInfoId)); return _productInfoDic[productInfoId]; } }
public static List<Store> GetAllStoreList(ProjectSIAEntities db, bool reload = false) { using (var rl = new ReadLock()) { if (_storeList == null || reload) { _storeList = db.Store.ToList().Select(x => new Store(x)).ToList(); } return _storeList; } }
public static Store GetLocalStore(ProjectSIAEntities db) { using (var rl = new ReadLock()) { var localStore = GetAllStoreList(db).Where(x => x.Type == StoreType.Local).FirstOrDefault(); if (localStore == null) { using (var wl = new WriteLock()) { var dbLocalStore = db.Store.Add(new ProjectSIA.Store() { name = "사무실", beginDate = new DateTime(2012, 1, 1), endDate = DateTime.MaxValue, type = StoreType.Local.ToString(), rule = StoreRule.None.ToString(), value = 0 }); var rows = db.SaveChanges(); if (rows != 1) throw new AutistarException("사무실 Store를 만드는 과정 중 DB 작업을 실패했습니다."); localStore = new Store(dbLocalStore); } } return localStore; } }
public static Order GetOrder(ProjectSIAEntities db, int orderId) { using (var rl = new ReadLock()) { var dbOrder = db.OrderInfo.Where(x => x.id == orderId).FirstOrDefault(); if (dbOrder == null) throw new AutistarException("등록되지 않은 주문번호입니다. (id: {0})".With(orderId)); return new Order(dbOrder); } }
public static List<Member> GetAllMemberList(ProjectSIAEntities db, bool reload = false) { using (var rl = new ReadLock()) { if (_memberList == null || reload) { _memberList = db.Member.ToList().Select(x => new Member(x)).ToList(); } return _memberList; } }
public static List<Order> GetAllOrderList(ProjectSIAEntities db) { using (var rl = new ReadLock()) { return db.OrderInfo.ToList().Select(x => new Order(x)).ToList(); } }
public static List<Product> GetByProductInfoIdAndStoreIdAndStatus(ProjectSIAEntities db, int productInfoId, int storeId, ProductStatus status) { using (var rl = new ReadLock()) { var statusString = status.ToString(); return db.Product.Where(x => x.productInfoId == productInfoId && x.storeId == storeId && x.status == statusString).ToList() .Select(x => new Product(x)).ToList(); } }
public static List<Product> GetByProductInfoId(ProjectSIAEntities db, int productInfoId) { using (var rl = new ReadLock()) { return db.Product.Where(x => x.productInfoId == productInfoId).ToList() .Select(x => new Product(x)).ToList(); } }
public static List<Product> GetAllProductList(ProjectSIAEntities db) { using (var rl = new ReadLock()) { return db.Product.ToList().Select(product => new Product(product)).ToList(); } }
public static Member GetDummyMember(ProjectSIAEntities db) { using (var rl = new ReadLock()) { var member = GetAllMemberList(db).Where(x => x.Name == "dummy").FirstOrDefault(); if (member == null) return AddNewMember(db, "dummy", "dummy", "dummy", ""); return member; } }
public static Designer GetDesigner(ProjectSIAEntities db, int designerId) { using (var rl = new ReadLock()) { var designer = GetAllDesingerList(db).Where(x => x.Id == designerId).FirstOrDefault(); if (designer == null) throw new AutistarException("등록되지 않은 디자이너입니다. (id: {0})".With(designerId)); return designer; } }
public static List<Designer> Search(ProjectSIAEntities db, string keyword) { using (var rl = new ReadLock()) { return GetAllDesingerList(db) .Where(x => x.Name.Contains(keyword)) .ToList(); } }
public static List<Store> GetCurrentOpenedStore(ProjectSIAEntities db) { using (var rl = new ReadLock()) { return GetAllStoreList(db).Where(x => x.BeginDate < DateTime.Now && x.EndDate > DateTime.Now).ToList(); } }
public static List<Designer> GetAllDesingerList(ProjectSIAEntities db, bool reload = false) { using (var rl = new ReadLock()) { if (_designerList == null || reload) { Caching(db); } return _designerList; } }
public static Store GetStore(ProjectSIAEntities db, int storeId) { using (var rl = new ReadLock()) { var store = GetAllStoreList(db).Where(x => x.Id == storeId).FirstOrDefault(); if (store == null) throw new AutistarException("등록되지 않은 행사장(거래처) 번호입니다. (id: {0})".With(storeId)); return store; } }
public static Member GetMember(ProjectSIAEntities db, int memberId) { using (var rl = new ReadLock()) { var member = GetAllMemberList(db).Where(x => x.Id == memberId).FirstOrDefault(); if (member == null) throw new AutistarException("등록되지 않은 사용자입니다. (id: {0})".With(memberId)); return member; } }