コード例 #1
0
 public static void DeleteObjectOfTransactionFromDb(ObjectOfTransaction objectOfTransaction)
 {
     using (var db = new DB_Context())
     {
         db.ObjectOfTransactions.Remove(db.ObjectOfTransactions.Find(objectOfTransaction.ObjectOfTransactionID));
         db.SaveChanges();
     }
 }
コード例 #2
0
 public static void AddUserToDb(User user)
 {
     using (var db = new DB_Context())
     {
         db.Users.Add(user);
         db.SaveChanges();
     }
 }
コード例 #3
0
 public static void AddObjectOfTransactionToDb(ObjectOfTransaction objectOfTransaction)
 {
     using (var db = new DB_Context())
     {
         db.ObjectOfTransactions.Add(objectOfTransaction);
         db.SaveChanges();
     }
 }
コード例 #4
0
 /// <summary>
 /// Delete obj from database
 /// </summary>
 /// <param name="deal"></param>
 public static void DeleteDealFromDb(Deal deal)
 {
     using (var db = new DB_Context())
     {
         db.Deals.Remove(db.Deals.Find(deal.DealID));
         db.ObjectOfTransactions.Find(deal.ObjectOfTransactionID).ObjectStateID = 1;
         db.SaveChanges();
     }
 }
コード例 #5
0
        /// <summary>
        /// Add new objects to database
        /// </summary>
        /// <param name="deal"></param>
        public static void AddDealToDb(Deal deal)
        {
            try
            {
                using (var db = new DB_Context())
                {
                    db.Deals.Add(deal);
                    db.ObjectOfTransactions.Find(deal.ObjectOfTransactionID).ObjectStateID = 2;
                    db.SaveChanges();
                }
            }
            catch (Exception EX)
            {

            }
        }
コード例 #6
0
 public static void DeleteUserFromDb(User user)
 {
     using (var db = new DB_Context())
     {
         db.Users.Remove(db.Users.Find(user.UserID));
         db.SaveChanges();
     }
 }
コード例 #7
0
        public static void UpdateUserFromDb(User user)
        {
            using (var db = new DB_Context())
            {
                var u = db.Users.Find(user.UserID);

                u.Name = user.Name;
                u.Surname = user.Surname;
                u.PhoneNumber = user.PhoneNumber;
                u.Email = user.Email;

                db.SaveChanges();
            }
        }
コード例 #8
0
        public static void UpdateObjectOfTransactionFromDb(ObjectOfTransaction objectOfTransaction)
        {
            using (var db = new DB_Context())
            {
                var obj = db.ObjectOfTransactions.Find(objectOfTransaction.ObjectOfTransactionID);
                obj.ObjectTypeID = objectOfTransaction.ObjectTypeID;
                obj.ServiceTypeID = objectOfTransaction.ServiceTypeID;
                obj.KindOfCalculatingID = objectOfTransaction.KindOfCalculatingID;
                obj.UserID = objectOfTransaction.UserID;
                obj.ObjectStateID = objectOfTransaction.ObjectStateID;
                obj.Cost = objectOfTransaction.Cost;
                obj.Description = objectOfTransaction.Description;

                db.SaveChanges();
            }
        }
コード例 #9
0
        /// <summary>
        /// Update objects from database
        /// </summary>
        /// <param name="deal"></param>
        public static void UpdateDealFromDb(Deal deal)
        {
            using (var db = new DB_Context())
            {
                var d = db.Deals.Find(deal.DealID);

                d.Buyer_UserID = deal.Buyer_UserID;
                d.Seller_UserID = deal.Seller_UserID;
                d.DateOfDeal = deal.DateOfDeal;
                d.PersonalNumberOfDeal = deal.PersonalNumberOfDeal;
                d.TransactionAmount = deal.TransactionAmount;
                d.KindOfCalculatingID = deal.KindOfCalculatingID;
                d.ObjectOfTransactionID = deal.ObjectOfTransactionID;

                db.ObjectOfTransactions.Find(deal.ObjectOfTransactionID).ObjectStateID = 2;
                db.SaveChanges();

            }
        }