public ActionResult PreviewBreakfastReport(string date, string showDate) { BreakFastReport model = new BreakFastReport(); model.Date = showDate; var results = reservationRepository.GetBreakfastReport(date, LogInManager.LoggedInUserId); model.Results = results; #region Record Activity Log RecordActivityLog.RecordActivity(Pages.SEARCH_REGISTRATION_CARD, "Generate Daily CashSheet Report."); #endregion //HTML to PDF string html = Utility.Utility.RenderPartialViewToString((Controller)this, "PreviewBreakfastReport", model); byte[] pdfBytes = Utility.Utility.GetPDF(html); return(File(pdfBytes, "application/pdf")); }
public ActionResult DeleteIndividualProfile(Guid id) { try { string profileId = string.Empty; //Delete Individual Profile. profileId = profileRepository.DeleteIndividualProfile(id, LogInManager.LoggedInUserId, LogInManager.LoggedInUserId); if (!string.IsNullOrWhiteSpace(profileId)) { #region Record Activity Log RecordActivityLog.RecordActivity(Pages.INDIVIDUAL_PROFILE, "Deleted profile."); #endregion return(Json(new { IsSuccess = true, data = new { ProfileId = id } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Individual profile not deleted successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "DeleteIndividualProfile"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }
public ActionResult LogoutUser(Guid id) { try { string userId = string.Empty; userId = userRepository.UpdateIsLoggedInFlag(id, false); if (!string.IsNullOrWhiteSpace(userId)) { RecordActivityLog.TrackUsersActivityByUserId_V2(id); return(Json(new { IsSuccess = true, data = new { UserId = userId } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "User not logged out successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "LogoutUser"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }
public ActionResult Login(LoginViewModel model) { try { if (!ModelState.IsValid) { return(View(model)); } var result = LogInManager.Login(model.Email, Utility.Utility.Encrypt(model.Password, Utility.Utility.EncryptionKey)); switch (result) { case LoginStatus.Success: RecordActivityLog.RecordActivity(Pages.LOGIN, "Loggedin successfully."); if (LogInManager.HasRights("STUDENT")) { //Create Dummy Reservation. TempReservation.CreateDummyReservation(); } if (model.RememberMe) { // Create a new cookie, Utility.Utility.WriteCookie("HotelierHubUserEmail", model.Email, 24); //24 Hours expiration time. } return(Json(new { IsSuccess = true, data = new { UserId = LogInManager.LoggedInUserId } }, JsonRequestBehavior.AllowGet)); case LoginStatus.AlreadyLoggedIn: return(Json(new { IsSuccess = false, errorMessage = "User already logged in!" }, JsonRequestBehavior.AllowGet)); case LoginStatus.InvalidLoginTime: var msg = "Please note your course is restricted; therefore, you can only access it during the times & day set by your Tutor."; return(Json(new { IsSuccess = false, errorMessage = msg }, JsonRequestBehavior.AllowGet)); case LoginStatus.Failure: default: RecordActivityLog.RecordActivity(Pages.LOGIN, "Login fail."); return(Json(new { IsSuccess = false, errorMessage = "Invalid Email and Password." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "Login POST"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }
public ActionResult CreateIndividualProfile(IndividualProfileVM model) { try { string profileId = string.Empty; model.CarRegistrationNo = Utility.Utility.ToUpperCase(model.CarRegistrationNo); model.CreatedBy = LogInManager.LoggedInUserId; profileId = profileRepository.AddIndividualProfile(model); if (!string.IsNullOrWhiteSpace(profileId)) { model.Id = Guid.Parse(profileId); #region Save Profile Preference Mapping var preferenceItems = model.PreferenceItems; if (!string.IsNullOrWhiteSpace(preferenceItems)) { var preferenceItemsArr = preferenceItems.Split(','); if (preferenceItemsArr != null) { //Remove Duplication. preferenceItemsArr = preferenceItemsArr.Distinct().ToArray(); foreach (var item in preferenceItemsArr) { //Save Profile Preference Mapping. ProfilePreferenceMappingVM profilePreferenceMapping = new ProfilePreferenceMappingVM(); profilePreferenceMapping.ProfileTypeId = model.ProfileTypeId; profilePreferenceMapping.PreferenceId = Guid.Parse(item); profilePreferenceMapping.ProfileId = Guid.Parse(profileId); profilePreferenceMapping.CreatedBy = LogInManager.LoggedInUserId; preferenceRepository.AddProfilePreferenceMapping(profilePreferenceMapping); } } } #endregion #region Profile Remarks if (model.RemarksList != null && model.RemarksList.Count > 0) { foreach (var remark in model.RemarksList) { remark.ProfileId = model.Id; remark.CreatedBy = LogInManager.LoggedInUserId; if (!remark.CreatedOn.HasValue) { remark.CreatedOn = DateTime.Now; } profileRepository.AddProfileRemark(remark); } } #endregion #region Record Activity Log RecordActivityLog.RecordActivity(Pages.INDIVIDUAL_PROFILE, string.Format("Created new profile of {0} {1}.", model.LastName, model.FirstName)); #endregion #region Check Source Parameters if (Request.Form["Source"] != null && !string.IsNullOrWhiteSpace(Convert.ToString(Request.Form["Source"]))) { string source = string.Empty; string url = string.Empty; string qid = string.Empty; source = Convert.ToString(Request.Form["Source"]); if (source == "RateQuery") { TempData["ProfileId"] = profileId; TempData["FirstName"] = model.FirstName; TempData["LastName"] = model.LastName; TempData["CountryId"] = model.CountryId; TempData["TelephoneNo"] = model.TelephoneNo; //TempData["Remarks"] = model.Remarks; url = Url.Action("RateQuery", "Reservation"); } else if (source == "CreateReservation") { TempData["TitleId"] = model.TitleId; TempData["ProfileId"] = profileId; TempData["FirstName"] = model.FirstName; TempData["LastName"] = model.LastName; TempData["CountryId"] = model.CountryId; TempData["TelephoneNo"] = model.TelephoneNo; //TempData["Remarks"] = model.Remarks; url = Url.Action("Create", "Reservation"); } else if (source == "EditReservation") { qid = Convert.ToString(Request.Form["Qid"]); TempData["TitleId"] = model.TitleId; TempData["ProfileId"] = profileId; TempData["FirstName"] = model.FirstName; TempData["LastName"] = model.LastName; TempData["CountryId"] = model.CountryId; TempData["TelephoneNo"] = model.TelephoneNo; //TempData["Remarks"] = model.Remarks; url = Url.Action("Edit", "Reservation", new { Id = qid }); } else if (source == "SearchArrivals") { TempData["TitleId"] = model.TitleId; TempData["ProfileId"] = profileId; TempData["FirstName"] = model.FirstName; TempData["LastName"] = model.LastName; TempData["CountryId"] = model.CountryId; TempData["TelephoneNo"] = model.TelephoneNo; //TempData["Remarks"] = model.Remarks; url = Url.Action("Arrivals", "FrontDesk"); } if (!string.IsNullOrWhiteSpace(url)) { return(Json(new { IsSuccess = true, IsExternalUrl = true, data = url }, JsonRequestBehavior.AllowGet)); } } #endregion return(Json(new { IsSuccess = true, data = new { ProfileId = model.Id } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Individual profile not saved successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "CreateIndividualProfile"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }
public ActionResult PrintMultipleRegistrationCard() { if (Session["ReservationIds"] == null || string.IsNullOrWhiteSpace(Convert.ToString(Session["ReservationIds"]))) { return(HttpNotFound()); } var reservationIds = (List <Guid>)Session["ReservationIds"]; StringBuilder html = new StringBuilder(); if (reservationIds != null && reservationIds.Count > 0) { foreach (var reservationId in reservationIds) { var reservation = reservationRepository.GetReservationById(reservationId, LogInManager.LoggedInUserId).FirstOrDefault(); if (reservation != null) { GuestRegistrationCardVM model = new GuestRegistrationCardVM(); #region Room Mapping //Get Room Mapping var selectedRooms = roomRepository.GetReservationRoomMapping(reservationId, null, LogInManager.LoggedInUserId); var roomIds = string.Empty; var roomNumbers = string.Empty; if (selectedRooms != null && selectedRooms.Count > 0) { foreach (var room in selectedRooms) { roomIds += string.Format("{0},", room.RoomId); roomNumbers += string.Format("{0}, ", room.RoomNo); } if (!string.IsNullOrWhiteSpace(roomNumbers)) { //Remove Last Comma. roomNumbers = Utility.Utility.RemoveLastCharcter(roomNumbers, ','); } } #endregion #region Profile var profile = new IndividualProfileVM(); if (reservation.ProfileId.HasValue) { profile = profileRepository.GetIndividualProfileById(reservation.ProfileId.Value, LogInManager.LoggedInUserId).FirstOrDefault(); } #endregion #region Title var title = new TitleVM(); if (profile.TitleId.HasValue) { title = titleRepository.GetTitlebyId(profile.TitleId.Value).FirstOrDefault(); } #endregion #region Room Type var roomType = new RoomTypeVM(); if (reservation.RoomTypeId.HasValue) { roomType = roomTypeRepository.GetRoomTypeById(reservation.RoomTypeId.Value).FirstOrDefault(); } #endregion #region Preference Mapping //Get Preference Mapping var selectedPreferences = preferenceRepository.GetReservationPreferenceMapping(reservation.Id, null, LogInManager.LoggedInUserId); var preferences = ""; if (selectedPreferences != null && selectedPreferences.Count > 0) { preferences = String.Join(", ", selectedPreferences.Select(m => m.PreferenceDescription)); if (!string.IsNullOrWhiteSpace(preferences)) { preferences = Utility.Utility.RemoveLastCharcter(preferences.Trim(), ','); } } model.Preferences = preferences; #endregion #region Package Mapping //Get Package Mapping var selectedPackages = reservationRepository.GetReservationPackageMapping(reservation.Id, null, LogInManager.LoggedInUserId).ToList(); if (selectedPackages != null) { model.Packages = selectedPackages; //model.PackageName = selectedPackage.PackageName; //model.PackagePrice = CurrencyManager.ParseAmountToUserCurrency(selectedPackage.PackagePrice, LogInManager.CurrencyCode); //model.PackageTotalAmount = CurrencyManager.ParseAmountToUserCurrency(selectedPackage.TotalAmount, LogInManager.CurrencyCode); } #endregion model.Id = reservation.Id; model.ConfirmationNo = reservation.ConfirmationNumber; model.ProfileId = reservation.ProfileId; model.Title = title.Title; model.Email = profile.Email; model.PhoneNo = profile.TelephoneNo; model.Name = (profile.FirstName + ' ' + profile.LastName); model.CarRegistrationNo = profile.CarRegistrationNo; #region Fetch Address var address = ""; if (!string.IsNullOrWhiteSpace(profile.Address)) { //address = profile.Address; address = profile.Address.Replace(",", Delimeter.SPACE); } else if (!string.IsNullOrWhiteSpace(profile.HomeAddress)) { //address = profile.HomeAddress; address = profile.HomeAddress.Replace(",", Delimeter.SPACE); } model.Address = address; if (!string.IsNullOrWhiteSpace(profile.CityName)) { //model.Address += !string.IsNullOrWhiteSpace(model.Address) ? (Delimeter.SPACE + profile.CityName) : profile.CityName; model.City = profile.CityName; } if (!string.IsNullOrWhiteSpace(profile.StateName)) { //model.Address += !string.IsNullOrWhiteSpace(model.Address) ? (Delimeter.SPACE + profile.StateName) : profile.StateName; model.State = profile.StateName; } if (profile.CountryId.HasValue) { var country = countryRepository.GetCountryById(profile.CountryId.Value).FirstOrDefault(); if (country != null) { model.Country = country.Name; } } //Split Address //if (!string.IsNullOrWhiteSpace(model.Address)) //{ // //var splitAddress = ExtensionMethod.SplitString(model.Address, 40); // var splitAddress = model.Address.SplitStringChunks(60); // if (splitAddress != null && splitAddress.Length > 0) // { // model.Address1 = splitAddress[0]; // if (splitAddress.Length > 1) { model.Address2 = splitAddress[1]; } // if (splitAddress.Length > 2) { model.Address3 = splitAddress[2]; } // } //} model.ZipCode = profile.ZipCode; #endregion model.RoomNumer = roomNumbers; model.ArrivalDate = reservation.ArrivalDate.HasValue ? reservation.ArrivalDate.Value.ToString("dd-MMM-yyyy") : ""; model.DepartureDate = reservation.DepartureDate.HasValue ? reservation.DepartureDate.Value.ToString("dd-MMM-yyyy") : ""; model.NoOfNights = reservation.NoOfNight; model.NoOfAdult = reservation.NoOfAdult; model.NoOfChildren = reservation.NoOfChildren; if (roomType != null) { model.RoomType = roomType.RoomTypeCode; } model.Rate = CurrencyManager.ParseAmountToUserCurrency(reservation.Rate, LogInManager.CurrencyCode); model.ConfirmationNo = reservation.ConfirmationNumber; //HTML to PDF html.Append(Utility.Utility.RenderPartialViewToString((Controller)this, "PreviewRegistrationCard", model)); } } } #region Record Activity Log RecordActivityLog.RecordActivity(Pages.SEARCH_ARRIVALS, "Generated multiple guest registration card report."); #endregion //Clear session. //Session["ReservationIds"] = null; byte[] pdfBytes = Utility.Utility.GetPDF(Convert.ToString(html)); //return File(pdfBytes, "application/pdf", string.Format("RegistrationCard_{0}.pdf", model.Id)); return(File(pdfBytes, "application/pdf")); }
public ActionResult ReverseCheckIn(Guid reservationId, string source = "") { try { var reservation = reservationRepository.GetReservationById(reservationId, LogInManager.LoggedInUserId).FirstOrDefault(); if (reservation != null) { #region Remove Rent Charges var roomRentCharge = additionalChargeRepository.GetAdditionalChargesByCode(AdditionalChargeCode.ROOM_RENT).FirstOrDefault(); var reservationCharge = reservationChargeRepository.GetReservationCharges(reservation.Id, roomRentCharge.Id, LogInManager.LoggedInUserId).FirstOrDefault(); if (reservationCharge != null) { reservationChargeRepository.DeleteReservationCharges(reservationCharge.Id, LogInManager.LoggedInUserId, LogInManager.LoggedInUserId); } #endregion #region Remove Reservation Charges reservationChargeRepository.DeleteReservationChargesByReservation(reservation.Id, LogInManager.LoggedInUserId, LogInManager.LoggedInUserId); #endregion #region Remove Reservation Log (Room Occupied) reservationLogRepository.DeleteReservationLogByReservation(reservation.Id, LogInManager.LoggedInUserId, LogInManager.LoggedInUserId); #endregion #region Update Reservation Check In Flag (FALSE) reservationRepository.UpdateReservationCheckInFlag(reservation.Id, false, LogInManager.LoggedInUserId); #endregion #region Remove Check In Details checkInCheckOutRepository.DeleteCheckInCheckOutDetailByReservation(reservation.Id, LogInManager.LoggedInUserId, LogInManager.LoggedInUserId); #endregion #region Update Reservation Status (NULL) reservationRepository.UpdateReservationStatus(reservation.Id, null, LogInManager.LoggedInUserId); #endregion #region Update Reservation Total Price double totalPrice = Utility.Utility.CalculateReservationTotalPrice(reservation.Id); //Update Total Price. reservationRepository.UpdateReservationTotalPrice(reservation.Id, totalPrice, LogInManager.LoggedInUserId); #endregion #region Update Reservation Total Balance. double totalGuestBalance = 0; //totalGuestBalance = Utility.Utility.CalculateTotalBalance(reservation.Id); //Update Total Balance. reservationRepository.UpdateReservationTotalBalance(reservation.Id, totalGuestBalance, LogInManager.LoggedInUserId); #endregion #region Update TrackReservationLog Status = False reservationRepository.UpdateTrackReservationLogStatusByReservationId(reservation.Id, false); #endregion #region Record Activity Log RecordActivityLog.RecordActivity(Pages.CHECKIN, string.Format("Reverse Checked in profile successfully. Name: {0} {1}, Comfirmation #: {2} ", reservation.LastName, reservation.FirstName, reservation.ConfirmationNumber)); #endregion return(Json(new { IsSuccess = true, data = new { ReservationId = reservationId } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Reverse check in not done successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "ReverseCheckIn"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }
public ActionResult CheckIn(CheckInPaymentMethodVM model) { try { if (!string.IsNullOrWhiteSpace(model.RoomIds)) { string strETAText = "10:00"; if (!string.IsNullOrWhiteSpace(model.CheckInTimeText)) { strETAText = model.CheckInTimeText; } var checkReservationOrNot = reservationRepository.GetPreviousReservationOrNot(Guid.Parse(model.RoomIds), model.CheckInDate, TimeSpan.Parse(strETAText), null, LogInManager.LoggedInUserId); if (checkReservationOrNot != null && checkReservationOrNot.Count > 0) { return(Json(new { IsSuccess = false, IsReservation = true, errorMessage = "Selected room already checked in by another user. please select check in (ETA) time after " + checkReservationOrNot.Select(m => m.DepartureDate != null ? m.DepartureDate.Value.ToString("dd MMM yyyy") : null).FirstOrDefault() + " " + checkReservationOrNot.Select(m => m.CheckOutTime != null ? m.CheckOutTime : null).FirstOrDefault() + "" }, JsonRequestBehavior.AllowGet)); } } CheckInCheckOutVM checkIn = new CheckInCheckOutVM(); ReservationChargeVM reservationCharge = new ReservationChargeVM(); //Get Reservation detail. var reservation = reservationRepository.GetReservationById(model.ReservationId, LogInManager.LoggedInUserId).FirstOrDefault(); if (reservation != null) { reservation.PaymentMethodId = model.PaymentMethodId; //Encrypt Credit Card# reservation.CreditCardNo = Utility.Utility.Encrypt(model.CreditCardNo, Utility.Utility.EncryptionKey); reservation.CardExpiryDate = model.CardExpiryDate; reservation.ArrivalDate = model.CheckInDate; if (model.RoomTypeId.HasValue) { reservation.RoomTypeId = model.RoomTypeId.Value; } DateTime dtDepartureDate; dtDepartureDate = model.CheckInDate.Value.AddDays(reservation.NoOfNight); reservation.DepartureDate = dtDepartureDate; string CheckInTimeText = model.CheckInTimeText; TimeSpan checkInTime = new TimeSpan(); if (!string.IsNullOrWhiteSpace(CheckInTimeText)) { string todayDate = DateTime.Now.ToString("dd/MM/yyyy"); string date = (todayDate + " " + CheckInTimeText); DateTime time = Convert.ToDateTime(date); checkInTime = time.TimeOfDay; reservation.ETA = checkInTime; } if (reservation.ETA.HasValue) { checkInTime = reservation.ETA.Value; } reservation.UpdatedBy = LogInManager.LoggedInUserId; reservationRepository.UpdateReservation(reservation); #region Save Room Rent Charges double totalPrice = Utility.Utility.CalculateReservationTotalPrice(reservation.Id); var roomRentCharge = additionalChargeRepository.GetAdditionalChargesByCode(AdditionalChargeCode.ROOM_RENT).FirstOrDefault(); reservationCharge = new ReservationChargeVM(); reservationCharge.ReservationId = reservation.Id; reservationCharge.AdditionalChargeId = roomRentCharge.Id; reservationCharge.AdditionalChargeSource = AdditionalChargeSource.ADDITIONAL_CHARGE; reservationCharge.Code = roomRentCharge.Code; reservationCharge.Description = roomRentCharge.Description; reservationCharge.TransactionDate = reservation.ArrivalDate; reservationCharge.Amount = totalPrice; reservationCharge.Qty = 1; reservationCharge.IsActive = true; reservationCharge.CreatedBy = LogInManager.LoggedInUserId; reservationChargeRepository.AddReservationCharges(reservationCharge); #endregion #region Save Reservation Room Mapping & Update Room Occupied Flag var roomIds = model.RoomIds; string[] roomIdsArr = null; if (!string.IsNullOrWhiteSpace(roomIds)) { roomIdsArr = roomIds.Split(','); if (roomIdsArr != null) { //Remove Duplication. roomIdsArr = roomIdsArr.Distinct().ToArray(); } } //Delete Existing Reservation Room Mapping. //roomRepository.DeleteReservationRoomMappingByReservation(reservation.Id, LogInManager.LoggedInUserId); #region Delete Room Mapping var roomMappings = roomRepository.GetReservationRoomMapping(reservation.Id, null, LogInManager.LoggedInUserId); if (roomMappings != null && roomMappings.Count > 0) { List <Guid> roomMappingIds = new List <Guid>(); foreach (var roomMapping in roomMappings) { if (roomMapping.RoomId.HasValue) { if (roomIdsArr == null || !roomIdsArr.Contains(roomMapping.RoomId.Value.ToString())) { roomMappingIds.Add(roomMapping.Id); } } } //Delete Room Mapping if (roomMappingIds != null && roomMappingIds.Count > 0) { foreach (var mappingId in roomMappingIds) { roomRepository.DeleteReservationRoomMapping(mappingId, LogInManager.LoggedInUserId, LogInManager.LoggedInUserId); } } } #endregion if (roomIdsArr != null) { foreach (var item in roomIdsArr) { //Save Reservation Room Mapping. ReservationRoomMappingVM reservationRoomMapping = new ReservationRoomMappingVM(); reservationRoomMapping.RoomId = Guid.Parse(item.Trim()); reservationRoomMapping.ReservationId = reservation.Id; reservationRoomMapping.CreatedBy = LogInManager.LoggedInUserId; reservationRoomMapping.UpdatedBy = LogInManager.LoggedInUserId; roomRepository.AddUpdateReservationRoomMapping(reservationRoomMapping); ////Update Room Occupied Flag. //roomRepository.UpdateRoomOccupiedFlag(Guid.Parse(item.Trim()), true, LogInManager.LoggedInUserId); ////Update Room Status CLEAN to DIRTY. //roomRepository.UpdateRoomCheckInStatus(Guid.Parse(item.Trim()), Guid.Parse(RoomStatusType.DIRTY), true, LogInManager.LoggedInUserId); //Commented by Raju: 22-JUNE-2018 (Due to functionality change) //#region Remove Existing Reservation & Room Mapping (Who selected this Room# but not checked in yet.) //reservationRepository.DeleteReservationAndRoomMappingByRoom(Guid.Parse(item.Trim()), reservation.Id, LogInManager.LoggedInUserId, LogInManager.LoggedInUserId); //#endregion //Commented by Raju: 22-JUNE-2018 (Due to functionality change) //#region Remove Existing Reservation who did just booking but not checked-in yet. //var reservationRoomMappingDetails = roomRepository.GetReservationRoomMappingByRoom(Guid.Parse(item.Trim()), reservation.Id, reservation.ArrivalDate, reservation.DepartureDate, LogInManager.LoggedInUserId); //if (reservationRoomMappingDetails != null && reservationRoomMappingDetails.Count > 0) //{ // foreach(var reservationRoomMappingDetail in reservationRoomMappingDetails) // { // //Delete Reservation. // reservationRepository.DeleteReservation(reservationRoomMappingDetail.ReservationId.Value, LogInManager.LoggedInUserId, LogInManager.LoggedInUserId); // //Delete Reservation Room Mapping. // roomRepository.DeleteReservationRoomMappingByReservation(reservationRoomMappingDetail.ReservationId.Value, LogInManager.LoggedInUserId, LogInManager.LoggedInUserId); // //Delete Reservation Log. // reservationLogRepository.DeleteReservationLog(reservationRoomMappingDetail.Id, LogInManager.LoggedInUserId, LogInManager.LoggedInUserId); // } //} //#endregion #region Add Reservation Log var lstReservationLog = reservationLogRepository.GetReservationLogDetails(model.ReservationId, Guid.Parse(item.Trim()), null, LogInManager.LoggedInUserId).FirstOrDefault(); if (lstReservationLog != null) { lstReservationLog.ReservationId = model.ReservationId; lstReservationLog.ProfileId = model.ProfileId; lstReservationLog.RoomId = Guid.Parse(item.Trim()); lstReservationLog.CheckInDate = model.CheckInDate.Value; lstReservationLog.CheckInTime = checkInTime; lstReservationLog.CheckOutDate = reservation.DepartureDate; lstReservationLog.RoomStatusId = Guid.Parse(RoomStatusType.DIRTY); lstReservationLog.IsActive = true; lstReservationLog.UpdatedBy = LogInManager.LoggedInUserId; reservationLogRepository.UpdateReservationLog(lstReservationLog); } else { ReservationLogVM reservationLog = new ReservationLogVM(); reservationLog.ReservationId = model.ReservationId; reservationLog.ProfileId = model.ProfileId; reservationLog.RoomId = Guid.Parse(item.Trim()); reservationLog.CheckInDate = model.CheckInDate.Value; reservationLog.CheckInTime = checkInTime; reservationLog.CheckOutDate = reservation.DepartureDate; reservationLog.RoomStatusId = Guid.Parse(RoomStatusType.DIRTY); reservationLog.IsActive = true; reservationLog.CreatedBy = LogInManager.LoggedInUserId; reservationLogRepository.AddReservationLog(reservationLog); } #endregion } } #endregion #region Save CheckIn Details checkIn.ReservationId = model.ReservationId; checkIn.ProfileId = model.ProfileId; checkIn.CheckInDate = model.CheckInDate.Value; checkIn.CheckInTime = checkInTime; checkIn.IsActive = true; checkIn.CreatedBy = LogInManager.LoggedInUserId; var checkInId = checkInCheckOutRepository.AddCheckInDetail(checkIn); #endregion #region Update Reservation Check In Flag reservationRepository.UpdateReservationCheckInFlag(model.ReservationId, true, LogInManager.LoggedInUserId); #endregion #region Update Reservation Status reservationRepository.UpdateReservationStatus(model.ReservationId, Guid.Parse(ReservationStatusName.CHECKEDIN), LogInManager.LoggedInUserId); #endregion #region Update Reservation Total Balance. double totalGuestBalance = Utility.Utility.CalculateTotalBalance(reservation.Id); //Update Total Balance. reservationRepository.UpdateReservationTotalBalance(reservation.Id, totalGuestBalance, LogInManager.LoggedInUserId); #endregion #region Update TrackReservationLog Status reservationRepository.UpdateTrackReservationLogStatusByReservationId(reservation.Id, true); #endregion #region Record Activity Log RecordActivityLog.RecordActivity(Pages.CHECKIN, string.Format("Checked in profile successfully. Name: {0} {1}, Comfirmation #: {2} ", reservation.LastName, reservation.FirstName, reservation.ConfirmationNumber)); #endregion return(Json(new { IsSuccess = true, data = new { CheckInId = checkInId, Name = model.Name } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Check In details not saved successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "CheckIn"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }
public ActionResult Create(ReservationChargeVM model) { try { string chargeId = string.Empty; model.CreatedBy = LogInManager.LoggedInUserId; model.AdditionalChargeSource = AdditionalChargeSource.ADDITIONAL_CHARGE; chargeId = reservationChargeRepository.AddReservationCharges(model); if (!string.IsNullOrWhiteSpace(chargeId)) { model.Id = Guid.Parse(chargeId); #region Update Reservation Total Balance. var reservation = new ReservationVM(); if (model.ReservationId.HasValue) { reservation = reservationRepository.GetReservationById(model.ReservationId.Value, LogInManager.LoggedInUserId).FirstOrDefault(); } double totalBalance = 0; if (reservation != null) { totalBalance = reservation.GuestBalance.HasValue ? reservation.GuestBalance.Value : 0; //Calculate total Amount. int qty = 1; if (model.Qty.HasValue) { qty = model.Qty.Value; } totalBalance = totalBalance + (model.Amount.HasValue ? (model.Amount.Value * qty) : 0); //totalBalance += model.Amount.HasValue ? model.Amount.Value : 0; //Update Total Balance. reservationRepository.UpdateReservationTotalBalance(reservation.Id, totalBalance, LogInManager.LoggedInUserId); } #endregion var transaction = new List <ReservationChargeVM>(); transaction.Add(model); #region Record Activity Log RecordActivityLog.RecordActivity(Pages.BILLING_TRANSACTION, "Added new biling transaction."); #endregion return(Json(new { IsSuccess = true, data = new { ChargeId = chargeId, Transaction = transaction, TotalBalance = totalBalance } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Charge not saved successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "Create"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }