Esempio n. 1
0
 public void Insert_Test()
 {
     using (var db = new EFDbContext())
     {
         //if (!db.MedicalPackages.Any())
         {
             db.MedicalPackages.Add(new MedicalPackage
                 {
                     Name = "常规体检(女)",
                     CategoryId = 1,
                     Type = 0,
                     MarketPrice = 2600,
                     Price = 2200,
                     Feature = "实用性",
                     ForTheCrowd = "屌丝们",
                     Recommends = "体重,身高",
                     Details = "具体的描述",
                     CreateOn = DateTime.Now,
                     CreatorId = 0,
                     Creator = "system",
                     Popularity = 0,
                     Sort = 0,
                     State = 1,
                     Sex = 2
                 });
             db.SaveChanges();
         }
         Assert.AreEqual(2, db.MedicalPackages.Count());
     }
 }
Esempio n. 2
0
        public void TestMethod1()
        {
            using (var db = new EFDbContext())
            {
                int count;
                var list = db.Paging<Diseases>(new DataPage
                    {
                        Table = "Diseases",
                        PrimaryKey = "DiseasesId",
                        Sort = "DiseasesId desc",
                        Fields = "*",
                        PageIndex = 5,
                        PageSize = 5,
                        Filter = "DiseasesDepartmentId=1012",
                        Group = ""
                    }, out count).ToList();
                Console.WriteLine(list.Select(t => new
                    {
                        t.DiseasesId,
                        t.DiseasesName,
                        t.DiseasesDepartmentId
                    }).ToJson());

                Console.WriteLine(count);
            }
        }
Esempio n. 3
0
 public void QueryTest()
 {
     using (var db = new EFDbContext())
     {
         var item = db.MedicalPackages.FirstOrDefault();
         Assert.AreNotEqual(null, item);
         Assert.AreEqual("常规体检", item.Category.Name);
     }
 }
Esempio n. 4
0
 public void InsertTest()
 {
     using (var db = new EFDbContext())
     {
         if (!db.PackageCategories.Any())
         {
             db.PackageCategories.Add(new PackageCategory
                 {
                     Name = "常规体检",
                     Sort = 0,
                     State = 1
                 });
             db.SaveChanges();
         }
         Assert.AreEqual(1, db.PackageCategories.Count());
     }
 }
Esempio n. 5
0
 public void InitModel()
 {
     using (var db = new EFDbContext())
     {
         var manager = new Manager
             {
                 UserName = "******",
                 PassWord = "******".Md5().ToLower(),
                 RealName = "罗勇",
                 State = (byte)StateType.Display,
                 CreateOn = DateTime.Now,
                 Mobile = "18782246531",
                 Role =
                     (ManagerRole.News | ManagerRole.Package | ManagerRole.Reservation | ManagerRole.Users |
                      ManagerRole.Health)
                         .GetValue()
             };
         db.Managers.Add(manager);
         //var item = db.Managers.FirstOrDefault();
         //item.Role = ManagerRole.News.GetValue();
         db.SaveChanges();
         Assert.IsNotNull(db.Managers.FirstOrDefault());
     }
 }
Esempio n. 6
0
File: User.cs Progetto: shoy160/tjzx
 private static int MemberLogin(string userName, string userPwd)
 {
     using (var db = new EFDbContext())
     {
         var uItem =
             db.Members.SingleOrDefault(t => t.UserName == userName);
         if (uItem == null)
             return -1;
         if (!uItem.PassWord.Equals(userPwd.Md5(), StringComparison.CurrentCultureIgnoreCase))
             return -2;
         var tick = Const.CreateGuid().Substring(5, 15);
         var user = new User
         {
             UserId = uItem.MemberId,
             UserName = uItem.UserName,
             Ticket = tick,
             Type = UserType.Manager.GetValue()
         };
         var ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddHours(2),
                                                    false, user.ToJson());
         var encryptedTicket = FormsAuthentication.Encrypt(ticket);
         uItem.Ticket = tick;
         uItem.LastLoginIp = Utils.GetRealIp();
         uItem.LastLoginTime = DateTime.Now;
         db.SaveChanges();
         CookieCls.Set(FormsAuthentication.FormsCookieName, encryptedTicket, CookieCls.GetHour(2));
         return 1;
     }
 }