コード例 #1
0
        public List<User> GetAllUsersWithCards(List<Card> cards )
        {
            using (var db = new BusinessCardScannerEntities())
            {
                db.Configuration.ProxyCreationEnabled = false;
                var users = GetAllUsers();

                List<User> usersWithCards = new List<User>();
                foreach (var user in users)
                {
                    bool done = false;
                    foreach (var card in cards)
                    {
                        if (!done)
                        {
                          if (user.Id == card.CreatedUserId)
                            {
                            usersWithCards.Add(user);
                            done = true;
                            }
                        }
                    }
                }
                return usersWithCards;
            }
        }
コード例 #2
0
 public User GetUserByUsername(string username)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         return db.User.FirstOrDefault(x => x.Username == username);
     }
 }
コード例 #3
0
 public User GetUserByPhoneNumber(string phoneNumber)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         return db.User.FirstOrDefault(x => x.PhoneNumber == phoneNumber);
     }
 }
コード例 #4
0
 public User GetUserById(int id)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         return db.User.FirstOrDefault(x => x.Id == id);
     }
 }
コード例 #5
0
 public List<Card> GetAllCardsByPhoneNumber(string phoneNumber)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         return db.Card.Where(x => x.IsDeleted == false && x.User.PhoneNumber == phoneNumber).ToList();
     }
 }
コード例 #6
0
 public List<User> GetAllUsers()
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         return db.User.ToList();
     }
 }
コード例 #7
0
 public List<Card> GetAllCardsById(int id)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         return db.Card.Where(x => x.IsDeleted == false && x.User.Id == id).ToList();
     }
 }
コード例 #8
0
 public void Add(User user)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         db.User.Add(user);
         db.SaveChanges();
     }
 }
コード例 #9
0
 public void CreateCardImage(CardImage cardImage)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         db.CardImage.Add(cardImage);
         db.SaveChanges();
     }
 }
コード例 #10
0
 public void Delete(int id)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         Card card = GetCard(id);
         card.IsDeleted = true;
        Update(card);
     }
 }
コード例 #11
0
 public void Add(Card card)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         card.User = null; // Lappeløsning.. ellers blev en ny bruger oprettet hver gang
        // card.EncodedImage = "ÆNDRET I DAL";
         db.Card.Add(card);
         db.SaveChanges();
     }
 }
コード例 #12
0
 /*public void Delete(int id)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         User user = GetUser(id);
         user.IsDeleted = true;
         Update(user);
     }
 }*/
 public void Update(User user)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
コード例 #13
0
 public CardImage GetImageByEncodedImage(string encodedImage)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         return db.CardImage.FirstOrDefault(x => x.EncodedImage.Equals(encodedImage));
     }
 }
コード例 #14
0
 public string GetEncodedImage(int id)
 {
     using (var db = new BusinessCardScannerEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         return db.CardImage.First(x => x.Id == id).EncodedImage;
     }
 }