using System; using System.Collections.Generic; using System.Text; using System.Linq; using OrderSystem.Entity; using OrderSystem.Entity.ViewModel; using System.Linq.Expressions; using Bowin.Common.Linq.Entity; using OrderSystem.Entity.ViewModel.SystemSetting; using Bowin.Common.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using System.Security.Cryptography; using Microsoft.VisualBasic; using Z.EntityFramework.Plus; using OrderSystem.Entity.Extensions; using Bowin.Common.Utility; using OrderSystem.Services.Common; namespace OrderSystem.Services.SystemSetting { public class UserService : IUserService { private OrderSystemContext DbContext { get; set; } public UserService(OrderSystemContext dbContext) { DbContext = dbContext; } public LoginUser GetLoginUserById(string mobile, string contractNo) { var sql = from u in DbContext.CVxIdClientPhoneMerge where u.ClientPhoneNo == mobile && u.ContractNo == contractNo select new LoginUser { UserID = u.ClientPhoneNo, UserName = u.ClientName, Mobile = u.ClientPhoneNo }; return sql.FirstOrDefault(); } public LoginUser GetLoginUserByVxId(string openID) { var sql = from u in DbContext.CVxIdClientPhoneMerge where u.VxId == openID select new LoginUser { UserID = u.ClientPhoneNo, UserName = u.ClientName, Mobile = u.ClientPhoneNo }; return sql.FirstOrDefault(); } public LoginUser GetUserById(string userID) { var sql = from u in DbContext.CVxIdClientPhoneMerge where u.ClientPhoneNo == userID select new LoginUser { UserID = u.ClientPhoneNo, UserName = u.ClientName, Mobile = u.ClientPhoneNo }; return sql.FirstOrDefault(); } public int UpdateUserOpenID(string userID, string openID) { /*var list = DbContext.CVxIdClientPhoneMerge.Where(e => e.ClientPhoneNo == userID).ToList(); list.ForEach(item => { item.VxId = openID; this.DbContext.CVxIdClientPhoneMerge.Update(item); });*/ this.DbContext.Database.SqlQuery($"update C_VxIdClientPhoneMerge set VxId='{openID}' where ClientPhoneNo = '{userID}'", null); return this.DbContext.SaveChanges(); } } }