public HotelBookingProcessModel GetDetail(long?id) { HotelBookingProcessModel _model = new HotelBookingProcessModel(); HotelMessageModel _msg = new HotelMessageModel(); if (id != null) { HotelItinearyModel _itinModel = new HotelItinearyModel(); HotelBookRepository _bookRep = new HotelBookRepository(); HotelBookDetailRepository _bookingDtlRep = new HotelBookDetailRepository(); HotelBookingDetailModel _bookingDtlModel = new HotelBookingDetailModel(); _bookingDtlModel = _bookingDtlRep.GetHotelBooking(id); _model.BookingDetail = _bookingDtlModel; _model.BookingRecordId = id.Value; _itinModel = _bookRep.GetItineary(id); _model.Itineary = _itinModel.Itineary; _model.Message = _bookingDtlModel.Message; } else { _msg.ActionMessage = "Invalid Operation."; _msg.MsgNumber = 1000; _msg.MsgStatus = true; _msg.MsgType = 2; _model.Message = _msg; } return(_model); }
public HotelBookingCancelModel FillForCancel(long?id) { HotelBookDetailRepository _dtlRep = new HotelBookDetailRepository(); HotelBookingCancelModel _model = new HotelBookingCancelModel(); _model.BookingDetail = _dtlRep.GetHotelBooking(id); _model.Message = _model.BookingDetail.Message; if (_model.BookingDetail.Message.MsgNumber == 1) { _model.BookingRecordId = id.Value; } return(_model); }
public HotelBookingCancelModel FillCanceledDetail(long?id) { HotelBookDetailRepository _dtlRep = new HotelBookDetailRepository(); HotelBookingCancelModel _model = new HotelBookingCancelModel(); HotelMessageModel _msg = new HotelMessageModel(); TravelPortalEntity.EntityModel _ent = new TravelPortalEntity.EntityModel(); if (id != null) { var obj = _ent.Htl_BookingCancelDetail.Where(x => x.BookingCancelId == id).FirstOrDefault(); if (obj != null) { _model.BookingDetail = _dtlRep.GetHotelBooking(obj.BookingRecordId); _model.CancellationCharge = obj.CancellationCharge == null ? 0 : obj.CancellationCharge.Value; _model.CancelStatus = obj.CancellationStatus; _model.CreatedOn = obj.CreatedDate; _model.RefundableAmount = obj.RefundableAmount; _model.Remark = obj.Remark; _model.BookingRecordId = id.Value; _model.BookingCancelId = obj.BookingCancelId; _model.IsProcessed = obj.IsProcessed == null ? false : obj.IsProcessed.Value; _msg.ActionMessage = "Success."; _msg.MsgNumber = 1; _msg.MsgStatus = false; _msg.MsgType = 0; _model.Message = _msg; } else { _msg.ActionMessage = "Invalid Opetration."; _msg.MsgNumber = 1000; _msg.MsgStatus = true; _msg.MsgType = 2; _model.Message = _msg; } } else { _msg.ActionMessage = "Invalid Opetration."; _msg.MsgNumber = 1000; _msg.MsgStatus = true; _msg.MsgType = 2; _model.Message = _msg; } return(_model); }
public HotelBookingProcessModel ProcessPendingBooking(long?id) { TravelPortalEntity.EntityModel _ent = new TravelPortalEntity.EntityModel(); int BaseCurrencyId = 0; int CurrencyCodeId = 0; string BaseCurrencyCode = System.Configuration.ConfigurationManager.AppSettings["HotelBaseCurrencyCode"]; string CurrencyCode = System.Configuration.ConfigurationManager.AppSettings["HotelCurrencyCode"]; var _BaseCurrencyCode = _ent.Currencies.Where(x => x.CurrencyCode.Trim() == BaseCurrencyCode).FirstOrDefault(); if (_BaseCurrencyCode != null) { BaseCurrencyId = _BaseCurrencyCode.CurrencyId == null ? 0 : _BaseCurrencyCode.CurrencyId; } var _CurrencyCode = _ent.Currencies.Where(x => x.CurrencyCode.Trim() == CurrencyCode).FirstOrDefault(); if (_CurrencyCode != null) { CurrencyCodeId = _CurrencyCode.CurrencyId == null ? 0 : _CurrencyCode.CurrencyId; } var _ExchangeRate = _ent.Core_FXRate.Where(x => x.BaseCurrencyID == BaseCurrencyId && x.CurrencyID == CurrencyCodeId).OrderByDescending(x => x.CreatedDate).FirstOrDefault(); decimal ExchangeRate = 1; if (_ExchangeRate != null) { ExchangeRate = (decimal)(_ExchangeRate.ExchangeRate == null ? 1 : _ExchangeRate.ExchangeRate == 0 ? 1 : _ExchangeRate.ExchangeRate); } HotelItinearyModel _itmodel = new HotelItinearyModel(); HotelBookingProcessModel _model = new HotelBookingProcessModel(); HotelMessageModel _msg = new HotelMessageModel(); HotelCore.GetHotelBooking.Request _getBookingReq = new HotelCore.GetHotelBooking.Request(); HotelCore.GetHotelBooking.Response _getBookingRes = new HotelCore.GetHotelBooking.Response(); HotelCore.AddHotelBookingDetail.Request _addBookingReq = new HotelCore.AddHotelBookingDetail.Request(); HotelCore.AddHotelBookingDetail.Response _addBookingRes = new HotelCore.AddHotelBookingDetail.Response(); HotelCore.Book.Request _bookingReq = new HotelCore.Book.Request(); HotelCore.API api = new HotelCore.API(); if (id != null) { var obj = _ent.Htl_BookingRecord.FirstOrDefault(x => x.BookingRecordId == id && x.IsProcessed == false); if (obj != null) { if (obj.BookingStatusCode.Trim() == "Pending") { _getBookingReq.BookingId = obj.GDSBookingId; _getBookingRes = api.GetHotelBooking(_getBookingReq); if (_getBookingRes.Status.StatusNumber == 0) { if (_getBookingRes.BookingDetail != null) { var _bookRecObj = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == id).FirstOrDefault(); _bookRecObj.BookingStatusCode = _getBookingRes.BookingDetail[0].BookingStatus.ToString(); _bookRecObj.BookingReferenceNo = _getBookingRes.BookingDetail[0].BookingRefNo; _bookRecObj.BookingConformationNo = _getBookingRes.BookingDetail[0].ConfirmationNo; _bookRecObj.LastCancilationDate = _getBookingRes.BookingDetail[0].LastCancellationDate; _bookRecObj.BookingStatusCode = _getBookingRes.BookingDetail[0].BookingStatus.ToString(); _bookRecObj.IsGetBookingDetail = true; _ent.ApplyCurrentValues(obj.EntityKey.EntitySetName, _bookRecObj); _ent.SaveChanges(); var _bookingRecord = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == id).FirstOrDefault(); _bookingReq.SessionId = _bookingRecord.SearchSessionId; _bookingReq.Index = _bookingRecord.SearchIndex; _bookingReq.CountryName = _bookingRecord.CountryName; HotelCore.Utility.PaymentInformation pinfo = new HotelCore.Utility.PaymentInformation(); pinfo.Amount = _bookingRecord.TotalChargeableAmount; _bookingReq.PaymentInfo = pinfo; List <HotelCore.Utility.Guest> Guest = new List <HotelCore.Utility.Guest>(); var _guest = _ent.Htl_BookingGuestDetail.Where(x => x.BookingRecordId == id); if (_guest != null) { if (_guest.Count() > 0) { foreach (var item in _guest) { HotelCore.Utility.Guest gu = new HotelCore.Utility.Guest(); gu.Age = item.Age; gu.Addressline1 = item.Address1; gu.Addressline2 = item.Address2; gu.Areacode = item.AreaPhCode; gu.City = item.City; gu.Country = item.Country; gu.Countrycode = item.CountryPhCode; gu.Email = item.Email; gu.FirstName = item.FirstName; gu.GuestType = item.GuestType.Trim() == "Child" ? HotelCore.Utility.HotelGuestType.Child : HotelCore.Utility.HotelGuestType.Adult; gu.LastName = item.LastName; gu.LeadGuest = item.IsLeadGuest; gu.MiddleName = item.MiddleName; gu.Phoneno = item.PhoneNo; gu.RoomIndex = item.RoomIndex; gu.State = item.GuestState; gu.Title = item.Title; gu.Zipcode = item.ZipCoade; Guest.Add(gu); } } } _bookingReq.Guest = Guest.ToArray(); _bookingReq.CreatedOn = CurrentDateTime; _bookingReq.DisplayExchangeRate = ExchangeRate; if (_getBookingRes.BookingDetail[0].BookingStatus.ToString() == "Confirmed") { _addBookingReq = api.FillAddBookingRequest(1, _getBookingRes, _bookingReq); _addBookingRes = api.AddHotelBookingDetail(_addBookingReq); if (_addBookingRes.Status.StatusNumber == 0) { var _bookRecObj1 = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == id).FirstOrDefault(); _bookRecObj.AddBookingRefId = _addBookingRes.ReferenceId; _bookRecObj.IsBookingAdded = true; _ent.ApplyCurrentValues(obj.EntityKey.EntitySetName, _bookRecObj1); _ent.SaveChanges(); } } } } } else if ((obj.IsProcessed == false && obj.IsGetBookingDetail == false && obj.BookingStatusCode.Trim() == "Confirmed") || (obj.IsBookingAdded == false)) { _getBookingReq.BookingId = obj.GDSBookingId; _getBookingRes = api.GetHotelBooking(_getBookingReq); if (_getBookingRes.Status.StatusNumber == 0) { if (_getBookingRes.BookingDetail != null) { var _bookRecObj = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == id).FirstOrDefault(); _bookRecObj.BookingStatusCode = _getBookingRes.BookingDetail[0].BookingStatus.ToString(); _bookRecObj.BookingReferenceNo = _getBookingRes.BookingDetail[0].BookingRefNo; _bookRecObj.BookingConformationNo = _getBookingRes.BookingDetail[0].ConfirmationNo; _bookRecObj.LastCancilationDate = _getBookingRes.BookingDetail[0].LastCancellationDate; _bookRecObj.IsGetBookingDetail = true; _ent.ApplyCurrentValues(obj.EntityKey.EntitySetName, _bookRecObj); _ent.SaveChanges(); var _bookingRecord = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == id).FirstOrDefault(); _bookingReq.SessionId = _bookingRecord.SearchSessionId; _bookingReq.Index = _bookingRecord.SearchIndex; _bookingReq.CountryName = _bookingRecord.CountryName; HotelCore.Utility.PaymentInformation pinfo = new HotelCore.Utility.PaymentInformation(); pinfo.Amount = _bookingRecord.TotalChargeableAmount; _bookingReq.PaymentInfo = pinfo; List <HotelCore.Utility.Guest> Guest = new List <HotelCore.Utility.Guest>(); var _guest = _ent.Htl_BookingGuestDetail.Where(x => x.BookingRecordId == id); if (_guest != null) { if (_guest.Count() > 0) { foreach (var item in _guest) { HotelCore.Utility.Guest gu = new HotelCore.Utility.Guest(); gu.Age = item.Age; gu.Addressline1 = item.Address1; gu.Addressline2 = item.Address2; gu.Areacode = item.AreaPhCode; gu.City = item.City; gu.Country = item.Country; gu.Countrycode = item.CountryPhCode; gu.Email = item.Email; gu.FirstName = item.FirstName; gu.GuestType = item.GuestType.Trim() == "Child" ? HotelCore.Utility.HotelGuestType.Child : HotelCore.Utility.HotelGuestType.Adult; gu.LastName = item.LastName; gu.LeadGuest = item.IsLeadGuest; gu.MiddleName = item.MiddleName; gu.Phoneno = item.PhoneNo; gu.RoomIndex = item.RoomIndex; gu.State = item.GuestState; gu.Title = item.Title; gu.Zipcode = item.ZipCoade; Guest.Add(gu); } } } _bookingReq.Guest = Guest.ToArray(); _bookingReq.CreatedOn = CurrentDateTime; _bookingReq.DisplayExchangeRate = ExchangeRate; _addBookingReq = api.FillAddBookingRequest(1, _getBookingRes, _bookingReq); _addBookingRes = api.AddHotelBookingDetail(_addBookingReq); if (_addBookingRes.Status.StatusNumber == 0) { var _bookRecObj1 = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == id).FirstOrDefault(); _bookRecObj1.AddBookingRefId = _addBookingRes.ReferenceId; _bookRecObj1.IsBookingAdded = true; _ent.ApplyCurrentValues(_bookRecObj1.EntityKey.EntitySetName, _bookRecObj1); _ent.SaveChanges(); } } } } else if (obj.IsVouchered == false) { _getBookingReq.BookingId = obj.GDSBookingId; _getBookingRes = api.GetHotelBooking(_getBookingReq); var _bookRecObj1 = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == id).FirstOrDefault(); _bookRecObj1.IsVouchered = _getBookingRes.BookingDetail[0].VoucherStatus; _bookRecObj1.IsProcessed = _getBookingRes.BookingDetail[0].VoucherStatus; _ent.ApplyCurrentValues(_bookRecObj1.EntityKey.EntitySetName, _bookRecObj1); _ent.SaveChanges(); } } var _bookRecObj2 = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == id).FirstOrDefault(); if (_bookRecObj2.IsBookingSuccess == true && _bookRecObj2.IsBookingAdded == true && _bookRecObj2.BookingStatusCode == "Confirmed") { _bookRecObj2.IsProcessed = true; _ent.ApplyCurrentValues(_bookRecObj2.EntityKey.EntitySetName, _bookRecObj2); _ent.SaveChanges(); } HotelItinearyModel _itinModel = new HotelItinearyModel(); HotelBookRepository _bookRep = new HotelBookRepository(); HotelBookDetailRepository _bookingDtlRep = new HotelBookDetailRepository(); _model.BookingDetail = _bookingDtlRep.GetHotelBooking(id); _itinModel = _bookRep.GetItineary(id); _model.Itineary = _itinModel.Itineary; if (_itinModel.Itineary.BookingStatusDesc == "Confirmed" || _itinModel.Itineary.IsProcessed == true) { _msg.ActionMessage = "Booking Success"; _msg.MsgNumber = 1; _msg.MsgStatus = true; _msg.MsgType = 0; _model.Message = _msg; } else { _msg.ActionMessage = "Booking can not complete try again."; _msg.MsgNumber = 1001; _msg.MsgStatus = true; _msg.MsgType = 2; _model.Message = _msg; } } else { _msg.ActionMessage = "Invalid Operation."; _msg.MsgNumber = 1000; _msg.MsgStatus = true; _msg.MsgType = 2; _model.Message = _msg; } return(_model); }
public HotelBookingCancelModel GetCancelRequestStatus(long?id) { HotelCore.GetHotelChangeRequestStatus.Response _res = new HotelCore.GetHotelChangeRequestStatus.Response(); HotelCore.GetHotelChangeRequestStatus.Request _req = new HotelCore.GetHotelChangeRequestStatus.Request(); HotelBookingCancelModel model = new HotelBookingCancelModel(); HotelMessageModel _msg = new HotelMessageModel(); TravelPortalEntity.EntityModel _ent = new TravelPortalEntity.EntityModel(); if (id != null) { var obj = _ent.Htl_BookingCancelDetail.Where(x => x.BookingCancelId == id).FirstOrDefault(); if (obj != null) { using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required)) { HotelCore.API _api = new HotelCore.API(); _req.ChangeRequestId = Convert.ToInt32(obj.CancellationReqId); _res = _api.GetHotelChangeRequestStatus(_req); obj.CancellationCharge = _res.CancellationCharge; obj.CancellationStatus = _res.ChangeRequestStatus.ToString(); obj.RefundableAmount = _res.RefundedAmount; _ent.ApplyCurrentValues(obj.EntityKey.EntitySetName, obj); _ent.SaveChanges(); if (_res.ChangeRequestStatus.ToString() == "Processed") { var obj1 = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == obj.BookingRecordId).FirstOrDefault(); obj1.IsCanceled = true; _ent.ApplyCurrentValues(obj1.EntityKey.EntitySetName, obj1); _ent.SaveChanges(); } ts.Complete(); } if (_res.ChangeRequestStatus.ToString() == "Processed") { _msg.ActionMessage = "Cancellation Success."; _msg.MsgNumber = 1; _msg.MsgStatus = true; _msg.MsgType = 0; model.Message = _msg; } else { _msg.ActionMessage = "Cancellation is " + _res.ChangeRequestStatus.ToString(); _msg.MsgNumber = 1000; _msg.MsgStatus = true; _msg.MsgType = 2; model.Message = _msg; } HotelBookDetailRepository _dtlRep = new HotelBookDetailRepository(); var obj3 = _ent.Htl_BookingCancelDetail.Where(x => x.BookingCancelId == id).FirstOrDefault(); model.CancellationCharge = obj3.CancellationCharge == null ? 0 : obj3.CancellationCharge.Value; model.RefundableAmount = obj3.RefundableAmount; model.CancelStatus = obj3.CancellationStatus; var BookingRecordId = _ent.Htl_BookingCancelDetail.Where(x => x.BookingCancelId == id).Select(x => x.BookingRecordId).SingleOrDefault();// model.BookingDetail = _dtlRep.GetHotelBooking(BookingRecordId); model.CreatedOn = obj3.CreatedDate; model.Remark = obj3.Remark; model.IsProcessed = obj3.IsProcessed == null ? false : obj3.IsProcessed.Value; } else { _msg.ActionMessage = "Invalid operation."; _msg.MsgNumber = 1000; _msg.MsgStatus = true; _msg.MsgType = 2; model.Message = _msg; } } else { _msg.ActionMessage = "Invalid operation."; _msg.MsgNumber = 1000; _msg.MsgStatus = true; _msg.MsgType = 2; model.Message = _msg; } return(model); }
public HotelBookingCancelModel Cancel(HotelBookingCancelModel model) { HotelCore.SendHotelChangeRequest.Response _res = new HotelCore.SendHotelChangeRequest.Response(); HotelCore.SendHotelChangeRequest.Request _req = new HotelCore.SendHotelChangeRequest.Request(); TravelPortalEntity.EntityModel _ent = new TravelPortalEntity.EntityModel(); HotelMessageModel _msg = new HotelMessageModel(); var obj = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == model.BookingRecordId).FirstOrDefault(); //checked null model.BookingRecordId var _cancelObj = _ent.Htl_BookingCancelDetail.Where(x => x.BookingRecordId == model.BookingRecordId).FirstOrDefault(); if (_cancelObj == null) { TravelPortalEntity.Htl_BookingCancelDetail _objCancel = new TravelPortalEntity.Htl_BookingCancelDetail { BookingRecordId = model.BookingRecordId, GDSBookingID = obj.GDSBookingId, GDSID = obj.GDSID, GDSSessionID = obj.SearchSessionId, CreatedBy = LoggedUserId, CreatedDate = CurrentDateTime, Remark = model.Remark }; _ent.AddToHtl_BookingCancelDetail(_objCancel); _ent.SaveChanges(); model.BookingCancelId = _objCancel.BookingCancelId; } else { var _cancel1 = _ent.Htl_BookingCancelDetail.Where(x => x.BookingRecordId == model.BookingRecordId).FirstOrDefault(); model.BookingCancelId = _cancel1.BookingCancelId; _cancel1.ModifiedBy = LoggedUserId; _cancel1.ModifiedDate = CurrentDateTime; _ent.ApplyCurrentValues(_cancel1.EntityKey.EntitySetName, _cancel1); _ent.SaveChanges(); } _req.BookingId = obj.GDSBookingId; _req.GDSID = obj.GDSID; _req.ConfirmationNo = obj.BookingReferenceNo; _req.Remarks = model.Remark; _req.Email = obj.RegEmail; _req.SessionId = obj.SearchSessionId; HotelCore.API _api = new HotelCore.API(); _res = _api.SendCancelRequest(_req); _res.ChangeRequestId = _res.ChangeRequestId == null ? "-1" : _res.ChangeRequestId; if (_res.IsCancilRequest == true) { using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required)) { TravelPortalEntity.EntityModel _ent1 = new TravelPortalEntity.EntityModel(); var _cancel = _ent1.Htl_BookingCancelDetail.Where(x => x.BookingCancelId == model.BookingCancelId).FirstOrDefault(); _cancel.CancellationReqId = _res.ChangeRequestId; _cancel.GDSSessionID = obj.SearchSessionId; _cancel.CancellationStatus = _res.ChangeRequestStatus.ToString(); _cancel.IsCancilRequest = _res.IsCancilRequest; _cancel.IsProcessed = _res.IsProcessed; _ent.ApplyCurrentValues(_cancel.EntityKey.EntitySetName, _cancel); _ent.SaveChanges(); if (_res.ChangeRequestStatus.ToString() == "Processed") { var _record = _ent.Htl_BookingRecord.Where(x => x.BookingRecordId == model.BookingRecordId).FirstOrDefault(); _record.IsCanceled = true; _ent.ApplyCurrentValues(_record.EntityKey.EntitySetName, _record); _ent.SaveChanges(); } if (_res.ChangeRequestId != null) { if (_res.ChangeRequestId != "") { if (_res.IsProcessed == true) { _ent.Htl_CancelSalesTransaction(UserTerminalId, model.BookingRecordId, LoggedAgentId, LoggedUserId); } } } ts.Complete(); } model.CancelRequestId = _res.ChangeRequestId; HotelBookDetailRepository _dtlRep = new HotelBookDetailRepository(); model.BookingDetail = _dtlRep.GetHotelBooking(model.BookingRecordId); model.CreatedOn = CurrentDateTime; if (_res.IsProcessed == true) { _msg.ActionMessage = "Cancel Success"; _msg.MsgNumber = 1; _msg.MsgStatus = true; _msg.MsgType = 0; model.Message = _msg; } else if (_res.IsCancilRequest == true) { _msg.ActionMessage = "Cancelllation is in process"; _msg.MsgNumber = 1000; _msg.MsgStatus = true; _msg.MsgType = 2; model.Message = _msg; } } else { _msg.ActionMessage = "Cancelllation Can not success."; _msg.MsgNumber = 1000; _msg.MsgStatus = true; _msg.MsgType = 2; model.Message = _msg; } model.Message = _msg; return(model); }