コード例 #1
0
        public async static Task <People> FindUser(string email, string password)
        {
            var passwordHash = HelperWorkWithData.GetHash(password);

            using (var db = new PeopleContext())
            {
                return(await db.People.FirstOrDefaultAsync(p => p.Password == passwordHash && p.Email == email));
            }
        }
コード例 #2
0
        public async static Task AddImg(int id, string file)
        {
            using (var db = new PeopleContext())
            {
                var people = await db.People.FirstOrDefaultAsync(p => p.id == id);

                if (people != null)
                {
                    people.Birthday        = HelperWorkWithData.TransformDate(people.Birthday);
                    people.Img             = file;
                    db.Entry(people).State = EntityState.Modified;
                    await db.SaveChangesAsync();
                }
            }
        }
コード例 #3
0
 public async static Task AddPeople(People people)
 {
     try
     {
         using (var db = new PeopleContext())
         {
             if (people.Password == null)
             {
                 people.Password = HelperWorkWithData.GetHash("123");
             }
             db.People.Add(people);
             await db.SaveChangesAsync();
         }
     }
     catch (Exception e)
     {
         logger.Info("Wrong person format: " + e.Message);
     }
 }