public IEnumerable <dynamic> GetPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount) { var query = BusinessRepository.GetQuery(); var queryTrader = TraderRepository.GetQuery(); var queryBrand = BrandRepository.GetQuery(); var title = nvl["title"]; if (!title.IsNullOrEmpty()) { query = query.Where(o => o.Title.Contains(title) || o.Byname.Contains(title)); } var q = from x in query select new { x.Id, x.Title, x.Byname, x.ById, x.CreateDT, x.CreateUID, x.Status, StateTitle = x.Status == 1 ? "可用" : "禁用", TraderNum = queryTrader.Count(o => ("," + o.BusinessScopeId + ",").Contains("," + x.ById + ",")) }; recordCount = q.Count(); return(q.ToPageList()); }
public List <Entity.Business> GetTreeList(System.Collections.Specialized.NameValueCollection nvl) { var query = BusinessRepository.GetQuery(); var queryTrader = TraderRepository.GetQuery(); var queryBrand = BrandRepository.GetQuery(); var queryPayLicense = PayLicenseRepository.GetQuery(); var title = nvl["title"]; if (!title.IsNullOrEmpty()) { query = query.Where(o => o.Title.Contains(title) || o.Byname.Contains(title)); } var q = from x in query select new { Id = x.Id, Title = x.Title, Byname = x.Byname, ById = x.ById, CreateDT = x.CreateDT, CreateUID = x.CreateUID, Status = x.Status, TraderNum = queryTrader.Count(o => ("," + o.BusinessScopeId + ",").Contains("," + x.ById + ",")), PayLicenseNum = queryPayLicense.Count(o => o.BusinessId1 == x.ById || o.BusinessId2 == x.ById), x.ParentId }; var buss = q.ToList().Select(x => new Business() { Id = x.Id, Title = x.Title, Byname = x.Byname, ById = x.ById, CreateDT = x.CreateDT, CreateUID = x.CreateUID, Status = x.Status, TraderNum = x.TraderNum, PayLicenseNum = x.PayLicenseNum, ParentId = x.ParentId }).ToList(); var list = new List <Entity.Business>(); foreach (var bu in buss.Where(o => o.ParentId.IsNullOrEmpty())) { SetChilds(bu, buss); list.Add(bu); } return(list); }
public OpResult SaveOrUpdate(CompanyAuthorize obj) { if (!TraderRepository.GetQuery(o => o.CID == obj.CID).Any()) { return(OpResult.Fail("商户不存在!")); } //if(!obj.RealmName.IsNullOrEmpty()) obj.RealmName=obj.RealmName.Trim(); //if(!obj.RealmName.IsNullOrEmpty() && RealmRepository.GetQuery(o => o.Name == obj.RealmName && o.Url!=obj.RealmUrl).Any()) // return OpResult.Fail("子域名已存在!"); obj.AppProper = obj.AppProper ?? "N"; obj.StoreProper = obj.StoreProper ?? "N"; obj.PosMinorDisp = obj.PosMinorDisp ?? "N"; obj.MemberShared = obj.MemberShared ?? "Y"; if (obj.Id == 0) { if (CompanyAuthorRepository.GetQuery(o => o.CID == obj.CID).Any()) { return(OpResult.Fail("该商户已存在,如果已过期,请选择续约方式")); } obj.CreateDT = DateTime.Now; obj.CreateUID = CurrentUser.UID; obj.ExpirationDT = DateTime.Parse(obj.EffectiveDT).AddMonths(obj.ValidityNum.GetValueOrDefault()).ToString("yyyy-MM-dd"); if (obj.RealmName.IsNullOrEmpty()) { CompanyAuthorRepository.Add(obj); } else { //CompanyAuthorRepository.Add(obj, false); //RealmRepository.Add(new Realm() { CID = obj.CID.Value, Name = obj.RealmName, State = Convert.ToInt16(obj.RealmState), Url = obj.RealmName + obj.RealmSuffixUrl }); } } else { var res = CompanyAuthorRepository.Get(obj.Id); var pwd = res.SupperPassword; obj.ToCopyProperty(res, new List <string>() { "CreateDT", "CreateUID", "CID", "MachineSN", "SerialNo" }); res.ExpirationDT = DateTime.Parse(obj.EffectiveDT).AddMonths(obj.ValidityNum.GetValueOrDefault()).ToString("yyyy-MM-dd"); if (obj.SupperPassword.IsNullOrEmpty()) { res.SupperPassword = pwd; } //if(!res.RealmName.IsNullOrEmpty()) //{ // var realm = RealmRepository.Find(o => o.Url == res.RealmUrl && o.CID==res.CID.Value); // if (realm == null) // { // realm = new Realm(); // realm.CID = res.CID.Value; // RealmRepository.Add(realm,false); // } // realm.Name = res.RealmName; // realm.Url = res.RealmName + res.RealmSuffixUrl; // realm.State = Convert.ToInt16(res.RealmState); //} //else if (res.RealmName.IsNullOrEmpty()) //{ // var reals = RealmRepository.GetQuery(o => o.Url == res.RealmUrl && o.CID == res.CID).ToList(); // RealmRepository.RemoveRange(reals, false); //} CompanyAuthorRepository.SaveChanges(); } return(OpResult.Success()); }