public IUserSnap GetUserSnap(string ticket, LoginType type) { var passport = MongoEntity.Get <Passport>(p => p.SecurityKey == ticket); if (passport == null) { return(null); } var profile = MongoEntity.Get <Profile>(p => p.SecurityKey == ticket); if (profile == null) { return(null); } IUserSnap snap = new UserSnap() { Id = profile.Id, SecurityKey = profile.SecurityKey, Name = profile.Name, Account = profile.Account, LoginCode = passport.GetLoginCode(type), LoginType = type, Email = profile.Email, RegisteredTime = profile.BsonObjectId.CreationTime }; Log(snap.Name + " do GetUserSnap"); return(snap); //return new UserInfo(profile.Id, profile.Account, profile.Name, profile.Email, (profile.Native == null ? "" : string.Format("{0}{1}{2}", profile.Region.Name, profile.Nationality.Name, profile.Native.Name)), DateTime.Now, profile.SecurityKey); }
public void TestEntityList() { School school = new School() { Name = "WinStudio" }; List <Department> depts = new List <Department>() { new Department() { Name = "Master" }, new Department() { Name = "Admin" } }; foreach (Department dept in depts) { school.Departments.Add(dept); } foreach (Student student in students) { school.Students.Add(student); } school.Save(); School sch = MongoEntity.Get <School>(school.Id); Console.WriteLine(sch.Name); }
public ComRet Login(string account, string password, ClientType client, string client_sn) { var passport = MongoEntity.Get <Passport>(p => p.Account == account && p.Password == password); if (passport == null) { return(Result(false, "账户名不正确")); } Profile profile = MongoEntity.Get <Profile>(p => p.Account == account); if (profile == null) { return(Result(false, "账户不合法")); } profile.Client = client; profile.ClientSN = client_sn; profile.Save(); passport.Ticket = BusinessAuthentication.GenTicket(profile); passport.Save(); return(Result(true, passport.Ticket)); }
public void InitModel(string id) { if (IsModelReady) { return; } _dto_T = MongoEntity.Get <T>(id); }
public ComRet GetProfile(string id) { var profile = MongoEntity.Get <Profile>(id); if (profile == null) { return(Result("不存在的用户")); } Log("GetProfile"); return(Result(profile)); }
public void TestUpdate() { Student student2 = grade.Pick <Student>(students[2].Id); student2.Age = 100; grade.Update(); var g = MongoEntity.Get <Grade>(grade.Id); Assert.AreEqual(student2.Age, g.Pick <Student>(student2.Id).Age); }
public ComRet UpdateInfo(string ticket, string telphone) { var passport = MongoEntity.Get <Passport>(p => p.Ticket == ticket); if (passport == null) { return(Result(false, "账户不存在")); } var profile = MongoEntity.Get <Profile>(p => p.Account == passport.Account); profile.Telphone = telphone; profile.Save(); return(Result(true)); }
public void TestSave() { Student student = new Student(); student.Name = "hyf"; student.Age = 30; student.Save(); MongoEntity.Save <Student>(students); var stud = MongoEntity.Get <Student>(student.Id); MongoEntity.Get <Student>(s => s.Name == "hyf" && s.Age > 33); Assert.AreEqual(student.Name, stud.Name); Assert.AreEqual(student.Age, stud.Age); }
public ComRet UpdateInfo(string ticket, string name, Gender gender) { var passport = MongoEntity.Get <Passport>(p => p.Ticket == ticket); if (passport == null) { return(Result(false, "账户不存在")); } var profile = MongoEntity.Get <Profile>(p => p.Account == passport.Account); profile.Name = name; profile.Gender = gender; profile.Save(); return(Result(true)); }
public void TestAdd() { grade.Update(); students[0].Name = "NameChanged"; students[0].Save(); var g = MongoEntity.Get <Grade>(grade.Id); Assert.AreSame(students[0].Name, grade.Pick <Student>(students[0].Id).Name); Assert.AreNotSame(grade.Pick <Student>(students[0].Id).Name, g.Pick <Student>(students[0].Id).Name); Assert.AreEqual(grade.Count <Student>(), g.Count <Student>()); Assert.AreEqual(grade.Count <Teacher>(), g.Count <Teacher>()); Assert.AreEqual(g.Count <Student>(), MongoEntity.Select <Student>(s => s.Age > 0).Count()); }
public void TestTypeTest() { TypeTest tt = new TypeTest(); tt.Name = "TypeTester"; tt.Bytes = Encoding.UTF8.GetBytes(tt.Name); tt.Save(); var dbtt = MongoEntity.Get <TypeTest>(tt.Id); string b64 = Convert.ToBase64String(tt.Bytes); Assert.AreEqual(tt.Name, dbtt.Name); Assert.AreEqual(tt.Bytes.Length, dbtt.Bytes.Length); Assert.AreEqual(tt.Bytes, dbtt.Bytes); }
public ComRet CheckIn(string account, string password, LoginType type, string code) { var pp = MongoEntity.Get <Passport>(p => p.Account == account); if (pp == null) { return(Result("用户名不正确")); } if (pp.Password != password) { return(Result("密码不正确")); } if (type == LoginType.Web && pp.WebCode != code) { pp.WebCode = code; pp.Save(); } else if (type != LoginType.Web && pp.ClientCode != code) { pp.ClientCode = code; pp.Save(); } return(Result(true, pp.SecurityKey)); }
public void InitDto(string id) { Tdto = MongoEntity.Get <T>(id); }
public DboModel(string id) { _dto_T = MongoEntity.Get <T>(id); }
public virtual T Get(Expression <Func <T, bool> > where) { return(MongoEntity.Get <T>(where)); }
public virtual T Get(string id) { return(MongoEntity.Get <T>(id)); }