public static void DeleteObjectOfTransactionFromDb(ObjectOfTransaction objectOfTransaction) { using (var db = new DB_Context()) { db.ObjectOfTransactions.Remove(db.ObjectOfTransactions.Find(objectOfTransaction.ObjectOfTransactionID)); db.SaveChanges(); } }
public static void AddUserToDb(User user) { using (var db = new DB_Context()) { db.Users.Add(user); db.SaveChanges(); } }
public static void AddObjectOfTransactionToDb(ObjectOfTransaction objectOfTransaction) { using (var db = new DB_Context()) { db.ObjectOfTransactions.Add(objectOfTransaction); db.SaveChanges(); } }
/// <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(); } }
/// <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) { } }
public static void DeleteUserFromDb(User user) { using (var db = new DB_Context()) { db.Users.Remove(db.Users.Find(user.UserID)); db.SaveChanges(); } }
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(); } }
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(); } }
/// <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(); } }