示例#1
0
 public IEnumerable <UploadedPicture> UsersPictures(int id)
 {
     using (var context = new PicturesDBDataContext(_connection))
     {
         return(context.UploadedPictures.Where(u => u.id == id).ToList());
     }
 }
示例#2
0
 public void delete(int id)
 {
     using (var context = new PicturesDBDataContext(_connection))
     {
         context.ExecuteCommand("delete from UploadedPictures where id = {0}", id);
     }
 }
示例#3
0
 public User GetUser(string email)
 {
     using (var context = new PicturesDBDataContext(_connection))
     {
         return(context.Users.FirstOrDefault(u => u.Email == email));
     }
 }
示例#4
0
        public UploadedPicture GetPic(int id)
        {
            using (var context = new PicturesDBDataContext(_connection))

            {
                return(context.UploadedPictures.FirstOrDefault(i => i.id == id));
            }
        }
示例#5
0
 public void Add(UploadedPicture picture)
 {
     using (var context = new PicturesDBDataContext(_connection))
     {
         context.UploadedPictures.InsertOnSubmit(picture);
         context.SubmitChanges();
     }
 }
示例#6
0
 public void TimesSeen(int id)
 {
     using (var context = new PicturesDBDataContext(_connection))
     {
         UploadedPicture image = context.UploadedPictures.FirstOrDefault(i => i.id == id);
         image.TimesSeen = image.TimesSeen + 1;
         context.SubmitChanges();
     }
 }
示例#7
0
 public User GetUser(string email, string password)
 {
     using (var context = new PicturesDBDataContext(_connection))
     {
         User user    = context.Users.FirstOrDefault(u => u.Email == email);
         bool correct = PasswordHelper.PasswordMatch(password, user.PasswordSalt, user.PasswordHash);
         if (correct)
         {
             return(user);
         }
         return(null);
     }
 }