public void insert(IBankerBooking newBankerBooking) { var bankerBooking = newBankerBooking.getBankerBookingDto(); bankerBookings.Add(bankerBooking); bankerBooking.id = bankerBookings.Count(); }
public void insert(IBankerBooking newBankerBooking) { var bankerBooking = newBankerBooking.getBankerBookingDto(); using (var transactionScope = new TransactionScope()) { using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServerConnString"].ConnectionString)) { LeadDal leadDal = new LeadDal(); leadDal.insert(bankerBooking); string sqlQuery = @"Insert INTO BankerBooking (LeadId, Company, ExistingClient, Query, BankingRegionID, PreferredDate, PreferredTimeSlotId) Values (@LeadId, @Company, @ExistingClient, @Query, @BankingRegionID, @PreferredDate, @PreferredTimeSlotId); SELECT CAST(SCOPE_IDENTITY() as bigint)"; var idobj = db.ExecuteScalar(sqlQuery, new { LeadId = bankerBooking.lead.id, Company = bankerBooking.company, existingClient = bankerBooking.existingClient, query = bankerBooking.query, bankingRegionId = bankerBooking.bankingRegion, preferredDate = bankerBooking.provisionalDate, preferredTimeSlotId = bankerBooking.provisionalTimeSlot }); bankerBooking.id = long.Parse(idobj.ToString()); } transactionScope.Complete(); } }
public void update(IBankerBooking bankerBooking) { var data = bankerBooking.getBankerBookingDto(); bankerBookings[Convert.ToInt32(data.id)] = data; }