public List <UserModels.UserModel> GetUserList() { var user_model = (from U in Entities.S_User join B in Entities.S_Branch on U.BranchID equals B.BranchID into LBranch from leftBranch in LBranch.DefaultIfEmpty() join L in Entities.S_Location on U.LocationID equals L.LocationID into LUser from leftUser in LUser.DefaultIfEmpty() select new UserModels.UserModel { UserID = U.UserID, UserName = U.UserName, UserPassword = U.UserPassword, BranchName = leftBranch.BranchName, LocationName = leftUser.LocationName }).ToList(); return(user_model.ToList()); }
public List <UserModels.UserModel> SearchUserData(string search) { var user = (from U in Entities.S_User join B in Entities.S_Branch on U.BranchID equals B.BranchID into LBranch from leftBranch in LBranch.DefaultIfEmpty() join L in Entities.S_Location on U.LocationID equals L.LocationID into LUser from leftUser in LUser.DefaultIfEmpty() where U.UserName.Contains(search) select new UserModels.UserModel { UserID = U.UserID, UserName = U.UserName, UserPassword = U.UserPassword, BranchName = leftBranch.BranchName, LocationName = leftUser.LocationName }).ToList(); return(user.ToList()); }
/// <summary> /// Get supplier detail information include products /// </summary> /// <param name="supplier_id">supplier id</param> /// <returns>Instance of BSupplier object</returns> public BSupplier GetSupplierFullInfo(int supplier_id, bool getProduct = false) { BSupplier supplier = null; using (KuanMaiEntities db = new KuanMaiEntities()) { supplier = (from s in db.Supplier join user in db.User on s.User_ID equals user.User_ID into LUser from l_user in LUser.DefaultIfEmpty() join shop in db.Shop on s.Shop_ID equals shop.Shop_ID into LShop from l_shop in LShop.DefaultIfEmpty() join city in db.Common_District on s.City_ID equals city.id into LCity from l_city in LCity.DefaultIfEmpty() join province in db.Common_District on s.Province_ID equals province.id into LProvince from l_province in LProvince.DefaultIfEmpty() where s.Supplier_ID == supplier_id select new BSupplier { ID = s.Supplier_ID, Name = s.Name, Address = s.Address, City = l_city != null ? new BArea { ID = l_city.id, Name = l_city.name } : new BArea { ID = 0, Name = "" }, ContactPerson = s.Contact_Person, Created = s.Create_Time, Created_By = l_user != null ? new BUser { ID = l_user.User_ID, Name = l_user.Name, Mall_ID = l_user.Mall_ID, Mall_Name = l_user.Mall_Name } : new BUser { ID = 0, Name = "", Mall_ID = "", Mall_Name = "" }, Enable = (bool)s.Enabled, Fax = s.Fax, Phone = s.Phone, Province = l_province != null ? new BArea { ID = l_province.id, Name = l_province.name } : new BArea { ID = 0, Name = "" }, Remark = s.Remark, Shop = l_shop != null ? new BShop { ID = l_shop.Shop_ID, Title = l_shop.Name } : new BShop { ID = 0, Title = "" } }).FirstOrDefault <BSupplier>(); if (supplier != null && getProduct) { List <BProduct> products = null; var productIds = from s in db.Product_Supplier where s.Supplier_ID == supplier.ID && s.Enabled == true select s.Product_ID; products = (from p in db.Product where p.Parent_ID == 0 && productIds.Contains(p.Product_ID) select new BProduct { ID = p.Product_ID, Title = p.Name }).ToList <BProduct>(); supplier.Products = products; } } return(supplier); }
/// <summary> /// /// </summary> /// <param name="user_id"></param> /// <param name="feature_id"></param> /// <param name="status_id"></param> /// <param name="page"></param> /// <param name="pageSize"></param> /// <param name="total"></param> /// <returns></returns> public List <BBug> SearchBugs(int user_id, int feature_id, int status_id, int page, int pageSize, out int total) { total = 0; List <BBug> bugs = null; if (page <= 0) { page = 1; } if (pageSize < 0) { pageSize = 20; } using (KuanMaiEntities db = new KuanMaiEntities()) { var tmp = from bug in db.Bug select bug; if (user_id > 0) { tmp = tmp.Where(b => b.Created_By == user_id); } if (feature_id > 0) { tmp = tmp.Where(b => b.Feature == feature_id); } if (status_id > 0) { tmp = tmp.Where(b => b.Status == status_id); } var tmpBugs = from bug in tmp join user in db.User on bug.Created_By equals user.User_ID into LUser from createdBy in LUser.DefaultIfEmpty() join feature in db.Bug_Feature on bug.Feature equals feature.ID into LFeature from l_feature in LFeature.DefaultIfEmpty() join user1 in db.User on bug.Resolved_By equals user1.User_ID into LUser1 from resolved in LUser1.DefaultIfEmpty() join status in db.Bug_Status on bug.Status equals status.ID into LStatus from l_status in LStatus.DefaultIfEmpty() select new BBug { Created = bug.Created, Description = bug.Description, Title = bug.Title, ID = bug.ID, Modified = (long)bug.Modified, Created_By = new BUser { ID = createdBy.User_ID, Name = createdBy.Name, Mall_Name = createdBy.Mall_Name }, Feature = new BBugFeature { ID = l_feature.ID, Name = l_feature.Description }, Resolved_By = resolved != null ? new BUser { ID = resolved.User_ID, Name = resolved.Name, Mall_Name = resolved.Mall_Name } : new BUser { ID = 0, Name = "", Mall_Name = "" }, Status = new BBugStatus { ID = l_status.ID, Name = l_status.Status }, Resolved = bug.Resolved != null?(long)bug.Resolved:0 }; total = tmpBugs.Count(); bugs = tmpBugs.OrderBy(b => b.ID).Skip((page - 1) * pageSize).Take(pageSize).ToList <BBug>(); } return(bugs); }
/// <summary> /// /// </summary> /// <param name="bug_id"></param> /// <returns></returns> public BBug GetBugInfo(int bug_id) { BBug bug = null; using (KuanMaiEntities db = new KuanMaiEntities()) { var tmp = from b in db.Bug join feature in db.Bug_Feature on b.Feature equals feature.ID into LFeature from l_feature in LFeature.DefaultIfEmpty() join user in db.User on b.Created_By equals user.User_ID into lCreatedBy from createdBy in lCreatedBy.DefaultIfEmpty() join user_r in db.User on b.Resolved_By equals user_r.User_ID into LResolved from resolved in LResolved.DefaultIfEmpty() join status in db.Bug_Status on b.Status equals status.ID into LStatus from l_status in LStatus.DefaultIfEmpty() where b.ID == bug_id select new BBug { Created = b.Created, Created_By = new BUser { ID = createdBy.User_ID, Name = createdBy.Name, Mall_Name = createdBy.Mall_Name }, Description = b.Description, Title = b.Title, Status = new BBugStatus { ID = l_status.ID, Name = l_status.Status }, ID = b.ID, Feature = new BBugFeature { ID = l_feature.ID, Name = l_feature.Description }, Modified = (long)b.Modified, Resolved_By = resolved != null ? new BUser { ID = resolved.User_ID, Name = resolved.Name, Mall_Name = resolved.Mall_Name } : new BUser { ID = 0, Name = "", Mall_Name = "" }, }; bug = tmp.FirstOrDefault <BBug>(); if (bug != null) { var tmpRes = from bs in db.Bug_Response join user in db.User on bs.Create_By equals user.User_ID into LUser from l_user in LUser.DefaultIfEmpty() where bs.BugID == bug_id select new BBugResponse { Created = bs.Created, Created_By = l_user != null ? new BUser { ID = l_user.User_ID, Name = l_user.Name, Mall_Name = l_user.Mall_Name } : new BUser { ID = 0, Name = "", Mall_Name = "" }, Description = bs.Description, ID = bs.ID }; bug.Responses = tmpRes.ToList <BBugResponse>(); } } return(bug); }
/// <summary> /// /// </summary> /// <param name="user_id"></param> /// <param name="action"></param> /// <param name="page"></param> /// <param name="pageSize"></param> /// <param name="total"></param> /// <returns></returns> public List <BUserActionLog> SearchUserActionLog(int user_id, int action, long date1, long date2, int page, int pageSize, out int total) { total = 0; List <BUserActionLog> actions = new List <BUserActionLog>(); using (KuanMaiEntities db = new KuanMaiEntities()) { var tmp = from log in db.User_Action_Log select log; if (user_id > 0) { tmp = tmp.Where(l => l.User_ID == user_id); } if (action > 0) { tmp = tmp.Where(l => l.Action == action); } if (page <= 0) { page = 1; } if (pageSize <= 0) { pageSize = 30; } if (date1 > 0) { tmp = tmp.Where(l => l.Created >= date1); } if (date2 > 0) { tmp = tmp.Where(l => l.Created <= date2); } total = tmp.Count(); actions = (from log in tmp join ac in db.User_Action on log.Action equals ac.Action_ID into LAction from l_ac in LAction.DefaultIfEmpty() join user in db.User on log.User_ID equals user.User_ID into LUser from l_user in LUser.DefaultIfEmpty() join shop in db.Shop on log.Shop_ID equals shop.Shop_ID into LShop from l_shop in LShop.DefaultIfEmpty() select new BUserActionLog { Action = new BUserAction { Action_Desc = l_ac.Action_Description, Action_ID = log.Action, Action_Name = l_ac.Action_Name, Created = l_ac.Created, ID = l_ac.ID }, Created = log.Created, Description = log.Description, ID = log.ID, User = new BUser { ID = log.User_ID, Name = l_user.Name, Mall_ID = l_user.Mall_ID, Mall_Name = l_user.Mall_Name }, Shop = l_shop != null ? new BShop { ID = log.Shop_ID, Title = l_shop.Name } : new BShop { ID = 0, Title = "" } }).OrderByDescending(a => a.ID).Skip((page - 1) * pageSize).Take(pageSize).ToList <BUserActionLog>(); } return(actions); }