public bool UpdateStatus(string requestNumber, string status, string updatedBy) { using (var transactionScope = new TransactionScope()) { try { //1. Update BookingRequests DB var bookingRequest = _bookingRequestsDbContext.BookingRequests .Where(b => b.RequestNumber == requestNumber) .FirstOrDefault(); bookingRequest.Status = status; bookingRequest.UpdatedBy = updatedBy; bookingRequest.UpdatedDate = DateTimeOffset.UtcNow; //2. Update Main DB var confirmedBooking = new BookingRequest(); Mapper.Map<BookingRequest, BookingRequest>(bookingRequest, confirmedBooking); SaveConfirmedBooking(confirmedBooking, updatedBy); _bookingRequestsDbContext.SaveChanges(); _mainDbContext.SaveChanges(); transactionScope.Complete(); return true; } catch (Exception ex) { _log.Error("UpdateStatus ERROR", ex); return false; } } }
private void SaveConfirmedBooking(BookingRequest confirmedBooking, string updatedBy) { confirmedBooking.UpdatedBy = null; confirmedBooking.UpdatedDate = null; confirmedBooking.CreatedDate = DateTimeOffset.UtcNow; confirmedBooking.CreatedBy = updatedBy; _mainDbContext.BookingRequests.Add(confirmedBooking); }
private void SendEmailToDeliveryOffice(BookingRequest bookingRequest) { var content = string.Format(File.ReadAllText(ConfigurationManager.AppSettings["EmailTemplate"] + "ParcelPickup.html", Encoding.Unicode), bookingRequest.RequestNumber, bookingRequest.PickUpAddress1, bookingRequest.PickUpAddress2, bookingRequest.PickUpAddressCity, bookingRequest.PickUpAddressCountry, bookingRequest.PickUpAddressPostal, bookingRequest.PickUpAddressProvince, bookingRequest.PickUpLatitue, bookingRequest.PickUpLongitute); _emailNotification.Send(ConfigurationManager.AppSettings["BackEndEmail"], new List<string> { ConfigurationManager.AppSettings["DeliveryOfficeEmail"] }, string.Format("Parcel Pickup-RequestNo-{0}", bookingRequest.RequestNumber), content); }
private void SendEmailForEnquiry(string replyMessage, BookingRequest bookingRequest) { var content = string.Format(File.ReadAllText(ConfigurationManager.AppSettings["EmailTemplate"] + "Enquiry.html", Encoding.Unicode), bookingRequest.RequestNumber, bookingRequest.RequestorFirstName, replyMessage); _emailNotification.Send(ConfigurationManager.AppSettings["BackEndEmail"], new List<string> { bookingRequest.RequestorEmail }, string.Format("Enquiry-RequestNo-{0}", bookingRequest.RequestNumber), content); }
public BookingRequest Create(BookingRequest bookingRequest) { return _dbContext.BookingRequests.Add(bookingRequest); }