Esempio n. 1
0
 public void updateBadgeTransaction(int Id, string receiver, string badge, string comment)
 {
     using (var conn = new SqlConnection(connectionString))
     {
         var    badgeReceiver = new UserDAO()[receiver].User_Id;
         var    sentbadge     = new BadgeDAO()[badge].Badge_Id;
         string sql           = @"update BadgeTransaction set Reciever = @badgeReceiver, Badge_Id = @sentbadge, Badge_Comment = @comment where bt_id = @Id";
         conn.Query(sql, new { badgeReceiver = badgeReceiver, sentbadge = sentbadge, comment = comment, Id = Id });
     }
 }
Esempio n. 2
0
 // this funciton gets an badge transaciton when given an id
 public BadgeTransaction getBTGivenId(int Id)
 {
     using (var conn = new SqlConnection(connectionString))
     {
         string sql      = @"select * from BadgeTransaction where bt_id = @BT_Id";
         var    bt       = conn.Query <BadgeTransaction>(sql, new { BT_Id = Id }).FirstOrDefault();
         var    sender   = new UserDAO().findPersonGivenId(bt.Sender);
         var    receiver = new UserDAO().findPersonGivenId(bt.Reciever);
         var    badge    = new BadgeDAO().findBadgeGivenId(bt.Badge_Id);
         bt.Sender_Object   = sender;
         bt.Receiver_Object = receiver;
         bt.Badge           = badge;
         return(bt);
     }
 }
Esempio n. 3
0
        public List <BadgeTransaction> getAllBadgeTransactions()
        {
            using (var conn = new SqlConnection(connectionString))
            {
                string sql    = @"select * from BadgeTransaction";
                var    result = conn.Query <BadgeTransaction>(sql).AsList();

                foreach (var bt in result)
                {
                    UserDAO  userdao  = new UserDAO();
                    BadgeDAO badgedao = new BadgeDAO();
                    bt.Sender_Object   = userdao.findPersonGivenId(bt.Sender);
                    bt.Receiver_Object = userdao.findPersonGivenId(bt.Reciever);
                    bt.Badge           = badgedao.findBadgeGivenId(bt.Badge_Id);
                }

                return(result);
            }
        }