Beispiel #1
0
 public ActionResult Index()
 {
     try
     {
         if (User.Identity.IsAuthenticated)
         {
             string userId = User.Identity.GetUserId();
             long   id     = 0;
             if (long.TryParse(userId, out id))
             {
                 if (id > 0)
                 {
                     CLayer.Role.Roles rle = BLayer.User.GetRole(id);
                     if (rle == CLayer.Role.Roles.Corporate || rle == CLayer.Role.Roles.CorporateUser)
                     {
                         return(View("~/Views/Account/Home.cshtml"));
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     { Common.LogHandler.HandleError(ex); }
     return(View());
 }
Beispiel #2
0
 public static long Savedoc(CLayer.B2B data)
 {
     DataLayer.B2B     b2b = new DataLayer.B2B();
     CLayer.Role.Roles rle = BLayer.User.GetRole(data.UserId);
     data.UserCode = GetCode(data.UserId, rle);
     data.Validate();
     return(b2b.Savedoc(data));
 }
Beispiel #3
0
 private async Task <bool> SendSms(long bookingId)
 {
     try
     {
         if (bookingId < 1)
         {
             return(false);
         }
         CLayer.Address        byUser  = BLayer.Bookings.GetBookedByUser(bookingId);
         List <CLayer.Address> forUser = BLayer.Bookings.GetBookedForUser(bookingId);
         if (byUser == null)
         {
             return(false);
         }
         if (forUser.Count == 0)
         {
             return(false);
         }
         CLayer.Role.Roles rle      = BLayer.User.GetRole(byUser.UserId);
         CLayer.Booking    details  = BLayer.Bookings.GetDetailsSMS(bookingId);
         CLayer.User       supplier = BLayer.Bookings.GetSupplierDetails(bookingId);
         try
         {
             string phone = forUser[0].Mobile;
             if (phone == "")
             {
                 phone = forUser[0].Phone;
             }
             string smsmsg = Common.SMSGateway.GetNewBookingMessage(forUser[0].Firstname + " " + forUser[0].Lastname, details.OrderNo, details.CheckIn.ToString("MMM dd,yyyy"),
                                                                    details.CheckOut.ToString("MMM dd,yyyy"), details.PropertyTitle, details.propertyCity, details.AccommodationTypeTitle, BLayer.Settings.GetValue(CLayer.Settings.STAYB_CONTACTNO));
             bool b = false;
             phone = Common.Utils.GetMobileNo(phone);
             if (phone != "")
             {
                 b = await Common.SMSGateway.Send(smsmsg, phone);
             }
             phone = Common.Utils.GetMobileNo(details.Mobile);
             if (phone != "")
             {
                 b = await Common.SMSGateway.Send(smsmsg, phone);
             }
             phone = Common.Utils.GetMobileNo(supplier.Mobile);
             if (phone != "")
             {
                 b = await Common.SMSGateway.Send(smsmsg, phone);
             }
         }
         catch (Exception ex)
         {
             Common.LogHandler.HandleError(ex);
         }
     }
     catch (Exception ex)
     {
         Common.LogHandler.HandleError(ex);
     }
     return(true);
 }
Beispiel #4
0
 //*Added by rahul on 28/02/2020 for storing order number in offlinebookings
 public static void SetOfflinePaymentRefNo(long bookingId, CLayer.Role.Roles userRole, string orderNo = "")
 {
     DataLayer.Booking book = new DataLayer.Booking();
     if (orderNo == "")
     {
         orderNo = GetRefNo(bookingId, userRole);
     }
     book.SetOfflinePaymentRefNo(bookingId, orderNo);
 }
 public static long SetCustomerPaymentRefNo(long OfflinePaymentId, CLayer.Role.Roles UserRole, string PaymentRefNo, Guid PaymentGuid)
 {
     DataLayer.OfflinePayment bk = new DataLayer.OfflinePayment();
     if (PaymentRefNo == " ")
     {
         PaymentRefNo = GetRefNo(OfflinePaymentId, UserRole);
     }
     return(bk.SetCustomerPaymentRefNo(OfflinePaymentId, PaymentRefNo, PaymentGuid));
 }
        public ActionResult Index()
        {
            Models.UserDocumentsModel data = new Models.UserDocumentsModel();
            long userid = Convert.ToInt64(User.Identity.GetUserId());

            data.B2BId  = userid;
            data.UserId = userid;
            CLayer.Role.Roles Usertype1 = BLayer.User.GetRole(userid);
            data.UserType = (int)Usertype1;
            return(View(data));
        }
 public ActionResult CustomerOfflinePay(Models.PaymentRequestModel data)
 {
     try
     {
         //long UserId = GetUserId();
         long                  UserId    = BLayer.OfflinePayment.GetOfflinePaymentUserID(data.PaymentGuid);
         CLayer.Address        byAddress = BLayer.Address.GetAddressOnUserId(UserId);
         CLayer.Address        adrs      = BLayer.Address.GetPrimaryOnUser(UserId);
         CLayer.OfflinePayment dt        = new CLayer.OfflinePayment();
         dt.Name            = byAddress.Firstname;
         dt.Amount          = data.GrandTotal;
         dt.ReferenceNumber = "";
         dt.Message         = "";
         dt.UserId          = UserId;
         dt.Address         = adrs.AddressText;
         dt.CountryId       = adrs.CountryId;
         dt.StateId         = adrs.State;
         dt.CityId          = data.CityId;
         if (adrs.City != null && adrs.City != "")
         {
             dt.City = adrs.City;
         }
         if (adrs.CityId > 0)
         {
             dt.City = BLayer.City.Get(adrs.CityId).Name;
         }
         dt.Email        = byAddress.Email;
         dt.Mobile       = adrs.Mobile;
         dt.ZipCode      = adrs.ZipCode;
         dt.CustomerGuid = data.PaymentGuid;
         dt.Gatewaytype  = (int)CLayer.ObjectStatus.Gateway.EBS;
         CLayer.Role.Roles rle   = BLayer.User.GetRole(UserId);
         long   OfflinePaymentId = BLayer.OfflinePayment.SaveInitialCustomerPaymentData(dt);
         string PaymentRefNo     = " ";
         long   OffPayId         = BLayer.OfflinePayment.SetCustomerPaymentRefNo(OfflinePaymentId, rle, PaymentRefNo, data.PaymentGuid);
         return(RedirectToAction("Index", "OfflinePaymentProcess", new { OfflinePaymentId = OfflinePaymentId }));
     }
     catch (Exception ex)
     {
         Common.LogHandler.HandleError(ex);
         return(RedirectToAction("Index", "Home"));
     }
 }
        public ActionResult SaveOfflinePay(Models.OfflinePaymentModel data)
        {
            try
            {
                long UserId = GetUserId();
                CLayer.OfflinePayment dt = new CLayer.OfflinePayment();
                dt.Name            = data.Name;
                dt.Amount          = data.Amount;
                dt.ReferenceNumber = data.ReferenceNumber;
                dt.Message         = data.Message;
                dt.UserId          = UserId;
                dt.Address         = data.Address;
                dt.CountryId       = data.CountryId;
                dt.StateId         = data.State;
                dt.CityId          = data.CityId;
                if (data.City != null && data.City != "")
                {
                    dt.City = data.City;
                }
                if (data.CityId > 0)
                {
                    dt.City = BLayer.City.Get(data.CityId).Name;
                }
                dt.Email   = data.Email;
                dt.Mobile  = data.Mobile;
                dt.ZipCode = data.ZipCode;

                dt.Gatewaytype = (int)CLayer.ObjectStatus.Gateway.EBS;
                CLayer.Role.Roles rle   = BLayer.User.GetRole(UserId);
                long   OfflinePaymentId = BLayer.OfflinePayment.SaveInitialPaymentData(dt);
                string PaymentRefNo     = " ";
                long   OffPayId         = BLayer.OfflinePayment.SetPaymentRefNo(OfflinePaymentId, rle, PaymentRefNo);
                return(RedirectToAction("Index", "OfflinePaymentProcess", new { OfflinePaymentId = OfflinePaymentId }));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #9
0
        public static string GetRefNo(long id, CLayer.Role.Roles userRole)
        {
            string ids = (id + BOOKING_ID_SEED).ToString("X");

            ids = ids.PadLeft(MAX_LENGTH_REFNO, '0');
            switch (userRole)
            {
            case CLayer.Role.Roles.Corporate:
            case CLayer.Role.Roles.CorporateUser:
                ids = REFNO_POSTFIX_CORP + ids;
                break;

            case CLayer.Role.Roles.Agent:
                ids = REFNO_POSTFIX_TRA + ids;
                break;

            default:
                ids = REFNO_POSTFIX_REG + ids;
                break;
            }
            return(ids);
        }
Beispiel #10
0
        // 1 = success, 0 = failed

        public static int BookAccommodations(List <CLayer.BookingAccDetails> bookingInfo, DateTime checkIn, DateTime checkOut, long userId, long bookingId, long offlinebookingId, string orderNo = "", List <CLayer.RoomStaysResult> objRoomStayResult = null, List <CLayer.Rates> pAmedusRates = null, int CountryID = 0)
        {
            long        PropId         = BLayer.Accommodation.GetPropertyId(bookingInfo[0].AccommodationId);
            decimal     tax            = BLayer.PropertyTax.GetTotalTax(PropId);
            long        InventoryAPIID = BLayer.Accommodation.GetInventoryAPIType(PropId);
            int         result         = 0;
            List <long> accIds         = new List <long>();

            //long PId = BLayer.Bookings.GetPropertyId(bookingId);


            foreach (CLayer.BookingAccDetails t in bookingInfo)
            {
                accIds.Add(t.AccommodationId);
            }
            //List<CLayer.Tax> taxes = BLayer.Tax.GetAll()
            List <CLayer.Rates> accrates;

            CLayer.Role.Roles rle = BLayer.User.GetRole(userId);
            if (rle == CLayer.Role.Roles.CorporateUser || rle == CLayer.Role.Roles.Corporate)
            {
                accrates = BLayer.Rate.GetTotalRates(accIds, checkIn, checkOut, CLayer.Role.Roles.Corporate, userId, InventoryAPIID);
            }
            else
            {
                accrates = BLayer.Rate.GetTotalRates(accIds, checkIn, checkOut, CLayer.Role.Roles.Customer, userId, InventoryAPIID);
            }

            int cnt, i;


            //Amadeus Rates
            int InventoryAPIType = BLayer.Property.GetInventoryAPITypeId(PropId);

            List <CLayer.Rates> AmedusRatesList = new List <CLayer.Rates>();

            if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus)
            {
                accrates = pAmedusRates;
            }
            //Amadeus Rates end

            cnt = bookingInfo.Count;
            CLayer.Booking bk  = new CLayer.Booking();
            CLayer.Booking bk1 = new CLayer.Booking();
            bk.BookingDate      = DateTime.Today;
            bk.CheckIn          = checkIn;
            bk.CheckOut         = checkOut;
            bk.NoOfDays         = (checkOut - checkIn).Days;
            bk.Status           = (int)CLayer.ObjectStatus.BookingStatus.Cart;
            bk.BookingId        = bookingId;
            bk.ByUserId         = userId;
            bk.InventoryAPIType = BLayer.Property.GetInventoryAPITypeId(PropId);

            bk.BookingId = BLayer.Bookings.SaveInitialData(bk);
            // CLayer.Role.Roles rle = (CLayer.Role.Roles) BLayer.User.GetRole(userId);
            BLayer.Bookings.SetPaymentRefNo(bk.BookingId, rle, orderNo);


            //*Added by rahul for saving initial data to offline bookings on 28/02/20
            bk1.BookingDate      = DateTime.Today;
            bk1.CheckIn          = checkIn;
            bk1.CheckOut         = checkOut;
            bk1.NoOfDays         = (checkOut - checkIn).Days;
            bk1.Status           = (int)CLayer.ObjectStatus.BookingStatus.Cart;
            bk1.BookingId        = offlinebookingId;
            bk1.ByUserId         = userId;
            bk1.InventoryAPIType = BLayer.Property.GetInventoryAPITypeId(PropId);
            bk1.BookingId        = BLayer.Bookings.SaveOfflineBookingInitialData(bk1);



            //*Added by rahul on 28/02/2020 for storing order number in offlinebookings
            BLayer.Bookings.SetOfflinePaymentRefNo(bk1.BookingId, rle, orderNo);
            //****

            bookingId = bk.BookingId;
            List <CLayer.BookingItem> items   = new List <CLayer.BookingItem>();
            List <CLayer.BookingItem> ofitems = new List <CLayer.BookingItem>();

            CLayer.BookingItem bitem;
            CLayer.BookingItem ofbitem;
            DateTime           lockIn = DateTime.Now;
            int minutes = 0;

            int.TryParse(BLayer.Settings.GetValue(CLayer.Settings.LOCKIN_TIME), out minutes);
            lockIn = lockIn.AddMinutes(minutes);



            //// change no of accommodation for external inventory
            //int InventoryAPIType = BLayer.Property.GetInventoryAPITypeId(PropId);
            //List<CLayer.Rates> newaccrates = new List<CLayer.Rates>();
            //if (InventoryAPIType != 0)
            //{
            //    if (accrates.Count > 0)
            //    {
            //        string HotelId = BLayer.Property.GetHotelId(PropId);
            //        if (HotelId != null && HotelId != "")
            //        {
            //            foreach (CLayer.Rates item in accrates)
            //            {
            //                string RoomId = BLayer.Accommodation.GetRoomId(item.AccommodationId);
            //                if (RoomId != null && RoomId != "")
            //                {
            //                    if (item.NoofAcc < 1)
            //                    {
            //                        item.NoofAcc = 10;
            //                    }
            //                }
            //                newaccrates.Add(item);
            //            }
            //        }
            //    }
            //}
            //if (newaccrates.Count == 0)
            //{
            //    newaccrates = accrates;
            //}


            CLayer.BookingItem bGDSCountryItem = new CLayer.BookingItem();

            for (i = 0; i < cnt; i++)
            {
                foreach (CLayer.Rates rt in accrates)
                {
                    if (bookingInfo[i].AccommodationId == rt.AccommodationId)
                    {
                        if (bookingInfo[i].AccCount <= rt.NoofAcc && bookingInfo[i].AccCount != 0)
                        {
                            bitem                    = new CLayer.BookingItem();
                            bitem.CheckIn            = checkIn;
                            bitem.CheckOut           = checkOut;
                            bitem.BookingId          = bookingId;
                            bitem.AccommodationId    = rt.AccommodationId;
                            bitem.ForUser            = userId;
                            bitem.NoOfAccommodations = bookingInfo[i].AccCount;
                            bitem.NoOfAdults         = bookingInfo[i].Adults;
                            bitem.NoOfChildren       = bookingInfo[i].Children;
                            bitem.NoOfGuests         = bookingInfo[i].Guest;
                            bitem.LockInTime         = lockIn;
                            bitem.Status             = (int)CLayer.ObjectStatus.StatusType.Active;
                            bitem.GDSCountry         = CountryID;
                            items.Add(bitem);
                            bitem.BookingItemId = BLayer.BookingItem.SaveIntialData(bitem);
                            bGDSCountryItem     = bitem;


                            //*Added by rahul for Saving BookingDetails data on 28/02/20
                            ofbitem                    = new CLayer.BookingItem();
                            ofbitem.CheckIn            = checkIn;
                            ofbitem.CheckOut           = checkOut;
                            ofbitem.BookingId          = bk1.BookingId;
                            ofbitem.AccommodationId    = rt.AccommodationId;
                            ofbitem.ForUser            = userId;
                            ofbitem.NoOfAccommodations = bookingInfo[i].AccCount;
                            ofbitem.NoOfAdults         = bookingInfo[i].Adults;
                            ofbitem.NoOfChildren       = bookingInfo[i].Children;
                            ofbitem.NoOfGuests         = bookingInfo[i].Guest;
                            ofbitem.LockInTime         = lockIn;
                            ofbitem.Status             = (int)CLayer.ObjectStatus.StatusType.Active;
                            ofbitem.GDSCountry         = CountryID;
                            ofitems.Add(ofbitem);
                            ofbitem.OfflineBookingItemId = BLayer.BookingItem.SaveIntialBookingDetailsData(ofbitem);
                        }
                    }
                }
            }

            //update gdscountry in booking items
            BLayer.BookingItem.SaveGDSCountry(bGDSCountryItem);


            //calculate tax and amount for each accommodation
            //considering booking is for accommodations in a single property
            long propertyId         = BLayer.Accommodation.GetPropertyId(accrates[0].AccommodationId);
            List <CLayer.Tax> taxes = BLayer.Tax.GetAllForProperty(propertyId, checkIn, bk.BookingDate);
            List <CLayer.Tax> onTotalAmountTaxes = taxes.Where(m => m.OnTotalAmount == true).OrderBy(m => m.PriceUpto).ToList();
            List <CLayer.Tax> ordinaryTaxes      = taxes.Where(m => m.OnTotalAmount == false).OrderBy(m => m.PriceUpto).ToList();
            decimal           totalTax           = 0;
            decimal           guestRate          = 0;
            decimal           tt         = 0;
            StringBuilder     ratApplied = new StringBuilder();

            foreach (CLayer.BookingItem item in items)
            {
                foreach (CLayer.Rates rat in accrates)
                {
                    if (item.AccommodationId == rat.AccommodationId)
                    {
                        totalTax = 0;
                        ratApplied.Clear();
                        guestRate = ((rat.GuestRate + rat.TotalGuestTax) * item.NoOfGuests);
                        if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus)
                        {
                            item.TotalAmount = (rat.Amount + rat.TotalRateTax);
                        }
                        else
                        {
                            item.TotalAmount = ((rat.Amount + rat.TotalRateTax) * item.NoOfAccommodations) + guestRate;
                        }

                        totalTax    = BLayer.Tax.GetTaxOnAmount(ordinaryTaxes, item.TotalAmount, item.BookingItemId);
                        totalTax    = totalTax + BLayer.Tax.GetTaxOnAmount(onTotalAmountTaxes, item.TotalAmount + totalTax, item.BookingItemId);
                        item.Amount = Math.Round((rat.SupplierRate * item.NoOfAccommodations) + (rat.SupplierGuestRate * item.NoOfGuests));
                        if (rat.RateChanges != null && rat.RateChanges.Count > 0)
                        {
                            for (int ri = 0; ri < rat.RateChanges.Count; ri++)
                            {
                                if (ratApplied.Length > 0)
                                {
                                    ratApplied.Append(",");
                                }
                                ratApplied.Append(rat.RateChanges[ri].StartDate);
                                ratApplied.Append("#");
                                tt = (decimal)Math.Round(rat.RateChanges[ri].DayTotalCharge + (rat.RateChanges[ri].DayTotalGuestCharge * item.NoOfGuests));
                                ratApplied.Append(tt);
                            }
                            tt = (decimal)Math.Round(rat.RateChanges[0].DayTotalCharge + (rat.RateChanges[0].DayTotalGuestCharge * item.NoOfGuests));
                        }
                        else
                        {
                            tt = 0;
                        }
                        item.FirstDayCharge = tt;
                        item.TotalTax       = totalTax;
                        if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus)
                        {
                            item.TotalRateTax  = Math.Round(rat.TotalRateTax);
                            item.TotalGuestTax = Math.Round(rat.TotalGuestTax);
                        }
                        else
                        {
                            item.TotalRateTax  = Math.Round(rat.TotalRateTax * item.NoOfAccommodations);
                            item.TotalGuestTax = Math.Round(rat.TotalGuestTax * item.NoOfGuests);
                        }

                        // include tax with amount
                        item.TotalAmount = Math.Round(item.TotalAmount);
                        item.GuestAmount = Math.Round(guestRate);

                        item.RatesApplied            = ratApplied.ToString();
                        item.CorporateDiscountAmount = rat.CorpDiscount;
                        item.CommissionSB            = rat.SBMarkup;
                        if (item.NoOfGuests > 0)
                        {
                            item.CommissionSB            += rat.SBGuestMarkup;
                            item.CorporateDiscountAmount += rat.CorpGuestDiscount;
                        }



                        BLayer.BookingItem.SaveAmounts(item);

                        // save tax rate for each bookingitemid

                        long BItId             = item.BookingItemId;
                        long BookId            = item.BookingId;
                        long Pid               = BLayer.Accommodation.GetPropertyId(rat.AccommodationId);
                        List <CLayer.Tax> tax1 = BLayer.Tax.GetPropertyTaxById(Pid);

                        foreach (CLayer.Tax tx in tax1)
                        {
                            decimal TaxAmountBItem = Math.Round(((tx.Rate / tax) * ((rat.TotalRateTax * item.NoOfAccommodations) + (rat.TotalGuestTax * item.NoOfGuests))));
                            BLayer.BookingItem.SaveBookingtaxdata(BookId, BItId, tx.TaxTitleId, tx.Rate, TaxAmountBItem);
                        }



                        if (rat.AppliedOffers != null && rat.AppliedOffers.Count > 0)
                        {
                            foreach (CLayer.BookingItemOffer bo in rat.AppliedOffers)
                            {
                                BLayer.BookingItem.AddOffer(item.BookingItemId, bo.OfferId, bo.OfferTitle);
                            }
                        }
                    }
                }
            }
            BLayer.Bookings.UpdateAmounts(bookingId);

            //***This is for saving rates for offline bookings - booking details
            foreach (CLayer.BookingItem item in ofitems)
            {
                foreach (CLayer.Rates rat in accrates)
                {
                    if (item.AccommodationId == rat.AccommodationId)
                    {
                        totalTax = 0;
                        ratApplied.Clear();
                        guestRate = ((rat.GuestRate + rat.TotalGuestTax) * item.NoOfGuests);
                        if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus)
                        {
                            item.TotalAmount = (rat.Amount + rat.TotalRateTax);
                        }
                        else
                        {
                            item.TotalAmount = ((rat.Amount + rat.TotalRateTax) * item.NoOfAccommodations) + guestRate;
                        }

                        totalTax    = BLayer.Tax.GetTaxOnAmount(ordinaryTaxes, item.TotalAmount, item.OfflineBookingItemId);
                        totalTax    = totalTax + BLayer.Tax.GetTaxOnAmount(onTotalAmountTaxes, item.TotalAmount + totalTax, item.OfflineBookingItemId);
                        item.Amount = Math.Round((rat.SupplierRate * item.NoOfAccommodations) + (rat.SupplierGuestRate * item.NoOfGuests));
                        if (rat.RateChanges != null && rat.RateChanges.Count > 0)
                        {
                            for (int ri = 0; ri < rat.RateChanges.Count; ri++)
                            {
                                if (ratApplied.Length > 0)
                                {
                                    ratApplied.Append(",");
                                }
                                ratApplied.Append(rat.RateChanges[ri].StartDate);
                                ratApplied.Append("#");
                                tt = (decimal)Math.Round(rat.RateChanges[ri].DayTotalCharge + (rat.RateChanges[ri].DayTotalGuestCharge * item.NoOfGuests));
                                ratApplied.Append(tt);
                            }
                            tt = (decimal)Math.Round(rat.RateChanges[0].DayTotalCharge + (rat.RateChanges[0].DayTotalGuestCharge * item.NoOfGuests));
                        }
                        else
                        {
                            tt = 0;
                        }
                        item.FirstDayCharge = tt;
                        item.TotalTax       = totalTax;
                        if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus)
                        {
                            item.TotalRateTax  = Math.Round(rat.TotalRateTax);
                            item.TotalGuestTax = Math.Round(rat.TotalGuestTax);
                        }
                        else
                        {
                            item.TotalRateTax  = Math.Round(rat.TotalRateTax * item.NoOfAccommodations);
                            item.TotalGuestTax = Math.Round(rat.TotalGuestTax * item.NoOfGuests);
                        }

                        // include tax with amount
                        item.TotalAmount = Math.Round(item.TotalAmount);
                        item.GuestAmount = Math.Round(guestRate);

                        item.RatesApplied            = ratApplied.ToString();
                        item.CorporateDiscountAmount = rat.CorpDiscount;
                        item.CommissionSB            = rat.SBMarkup;
                        item.SellRateAfterTax        = rat.SellRateAfterTax;
                        item.SellRateBeforeTax       = rat.SellRateBeforeTax;
                        item.PurchaseRateAfterTax    = rat.PurchaseRateAfterTax;
                        item.PurchaseRateBeforeTax   = rat.PurchaseRateBeforeTax;
                        if (item.NoOfGuests > 0)
                        {
                            item.CommissionSB            += rat.SBGuestMarkup;
                            item.CorporateDiscountAmount += rat.CorpGuestDiscount;
                        }



                        BLayer.BookingItem.SaveBookingDetailsAmounts(item);

                        // save tax rate for each bookingitemid

                        long BItId             = item.BookingItemId;
                        long BookId            = item.BookingId;
                        long Pid               = BLayer.Accommodation.GetPropertyId(rat.AccommodationId);
                        List <CLayer.Tax> tax1 = BLayer.Tax.GetPropertyTaxById(Pid);

                        foreach (CLayer.Tax tx in tax1)
                        {
                            decimal TaxAmountBItem = Math.Round(((tx.Rate / tax) * ((rat.TotalRateTax * item.NoOfAccommodations) + (rat.TotalGuestTax * item.NoOfGuests))));
                            BLayer.BookingItem.SaveOfflineBookingtaxdata(BookId, BItId, tx.TaxTitleId, tx.Rate, TaxAmountBItem);
                        }



                        if (rat.AppliedOffers != null && rat.AppliedOffers.Count > 0)
                        {
                            foreach (CLayer.BookingItemOffer bo in rat.AppliedOffers)
                            {
                                BLayer.BookingItem.AddOffer(item.BookingItemId, bo.OfferId, bo.OfferTitle);
                            }
                        }
                    }
                }
            }

            BLayer.Bookings.UpdateOfflinebookingAmounts(bk1.BookingId);



            //add paypal commision outside india users
            long UserId = BLayer.Bookings.GetBookedByUserId(bookingId);

            CLayer.User dat = BLayer.User.GetCountrUser(UserId);
            string      ct  = dat.Country;

            if (ct != "India")
            {
                decimal paypalcomm         = Convert.ToDecimal(BLayer.Settings.GetValue(CLayer.Settings.PAYPAL_COMMISSION));
                decimal GrandTotalAmt      = Math.Round(BLayer.Bookings.GetTotal(bookingId));
                decimal TotalAmtIncPayComm = Math.Round(GrandTotalAmt + (paypalcomm * GrandTotalAmt / 100));
                BLayer.Bookings.SavePaypalComm((GrandTotalAmt * paypalcomm / 100), bookingId);
                BLayer.Bookings.UpdateTotalAmtIncPayComm(TotalAmtIncPayComm, bookingId);
                BLayer.Bookings.UpdateOfflineBookingTotalAmtIncPayComm(TotalAmtIncPayComm, bk1.BookingId);
            }



            //PartialPaymentbooking

            CLayer.Role.Roles UsertypeId        = BLayer.User.GetRole(userId);
            decimal           Partialamountperc = 0;

            if (UsertypeId == CLayer.Role.Roles.Customer)
            {
                Partialamountperc = Math.Round(BLayer.Property.GetPropertyB2CpartialamountPerc(propertyId));
            }
            if (UsertypeId == CLayer.Role.Roles.Administrator || UsertypeId == CLayer.Role.Roles.Corporate || UsertypeId == CLayer.Role.Roles.Affiliate || UsertypeId == CLayer.Role.Roles.Supplier || UsertypeId == CLayer.Role.Roles.CorporateUser)
            {
                Partialamountperc = Math.Round(BLayer.Property.GetPropertyB2BpartialamountPerc(propertyId));
            }

            decimal Partialamount   = Math.Round((Partialamountperc * Math.Round(BLayer.Bookings.GetTotal(bookingId))) / 100);
            decimal remainingamount = Math.Round(Math.Round(BLayer.Bookings.GetTotal(bookingId)) - Partialamount);

            BLayer.BookingItem.SavePartialAmount(bookingId, Partialamountperc, Partialamount, remainingamount);

            result = 1;

            return(result);
        }
        //Confirm Booking
        public async Task <bool> BookingConfirm(long bookingId)
        {
            try
            {
                BLayer.Bookings.SetStatus((int)CLayer.ObjectStatus.BookingStatus.Success, bookingId);

                //send customer email/message
                //email
                if (bookingId < 1)
                {
                    return(false);
                }
                CLayer.Address        byUser   = BLayer.Bookings.GetBookedByUser(bookingId);
                List <CLayer.Address> forUser  = BLayer.Bookings.GetBookedForUser(bookingId);
                CLayer.Booking        details  = BLayer.Bookings.GetDetailsSMS(bookingId);
                CLayer.User           supplier = BLayer.Bookings.GetSupplierDetails(bookingId);
                if (byUser == null)
                {
                    return(false);
                }
                if (forUser.Count == 0)
                {
                    return(false);
                }
                CLayer.Role.Roles rle = BLayer.User.GetRole(byUser.UserId);
                try
                {
                    string        message = "";
                    Common.Mailer ml      = new Common.Mailer();
                    //for normal user mail body
                    message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("BConfirmationMail") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));

                    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                    //guest mail added
                    msg.To.Add(forUser[0].Email);
                    if (forUser[0].Email != byUser.Email)
                    {
                        msg.CC.Add(byUser.Email);
                    }
                    //for corporate admins
                    if (rle == CLayer.Role.Roles.CorporateUser)
                    {
                        //  message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("CorpIntimation") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));
                        long cid = BLayer.B2B.GetCorporateIdOfUser(byUser.UserId);
                        if (cid > 0)
                        {
                            string em = BLayer.User.GetEmail(cid);
                            if (em != null && em != "")
                            {
                                msg.CC.Add(em);
                            }
                        }
                    }
                    msg.Subject = "Booking Confirmation";
                    msg.Body    = message;

                    msg.IsBodyHtml = true;

                    try
                    {
                        await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }

                    //message
                    if (bookingId < 1)
                    {
                        return(false);
                    }
                    if (byUser == null)
                    {
                        return(false);
                    }
                    if (forUser.Count == 0)
                    {
                        return(false);
                    }
                    try
                    {
                        string phone = forUser[0].Mobile;
                        if (phone == "")
                        {
                            phone = forUser[0].Phone;
                        }
                        string smsmsg = Common.SMSGateway.GetNewBookingMessage(forUser[0].Firstname + " " + forUser[0].Lastname, details.OrderNo, details.CheckIn.ToString("MMM dd,yyyy"),
                                                                               details.CheckOut.ToString("MMM dd,yyyy"), details.PropertyTitle, details.propertyCity, details.AccommodationTypeTitle, BLayer.Settings.GetValue(CLayer.Settings.STAYB_CONTACTNO));
                        bool b = false;
                        phone = Common.Utils.GetMobileNo(phone);

                        if (phone != "")
                        {
                            b = await Common.SMSGateway.Send(smsmsg, phone);
                        }
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }


                    //send supplier email/message

                    //message
                    if (bookingId < 1)
                    {
                        return(false);
                    }
                    if (byUser == null)
                    {
                        return(false);
                    }
                    if (forUser.Count == 0)
                    {
                        return(false);
                    }
                    try
                    {
                        string phone = forUser[0].Mobile;
                        if (phone == "")
                        {
                            phone = forUser[0].Phone;
                        }
                        string smsmsg = Common.SMSGateway.GetNewBookingMessage(forUser[0].Firstname + " " + forUser[0].Lastname, details.OrderNo, details.CheckIn.ToString("MMM dd,yyyy"),
                                                                               details.CheckOut.ToString("MMM dd,yyyy"), details.PropertyTitle, details.propertyCity, details.AccommodationTypeTitle, BLayer.Settings.GetValue(CLayer.Settings.STAYB_CONTACTNO));
                        bool b = false;
                        phone = Common.Utils.GetMobileNo(phone);

                        if (phone != "")
                        {
                            b = await Common.SMSGateway.Send(smsmsg, phone);
                        }
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }

                    //email
                    if (bookingId < 1)
                    {
                        return(false);
                    }
                    try
                    {
                        if (supplier.Email != "" || details.PropertyEmail != "")
                        {
                            if (supplier.Email == "")
                            {
                                supplier.Email        = details.PropertyEmail;
                                details.PropertyEmail = "";
                            }
                            message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupplierIntimation") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));

                            System.Net.Mail.MailMessage supplierMsg = new System.Net.Mail.MailMessage();
                            supplierMsg.To.Add(supplier.Email);
                            supplierMsg.Subject = "Booking Confirmation";
                            supplierMsg.Body    = message;

                            if (details.PropertyEmail != "")
                            {
                                supplierMsg.To.Add(details.PropertyEmail);
                            }
                            supplierMsg.IsBodyHtml = true;

                            try
                            {
                                await ml.SendMailAsync(supplierMsg, Common.Mailer.MailType.Reservation);
                            }
                            catch (Exception ex)
                            {
                                Common.LogHandler.HandleError(ex);
                            }
                        }
                    }


                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Beispiel #12
0
        public async Task <bool> ResendemailSGST(long OfflineBookingId, long BookingDetailsId, string key)
        {
            try
            {
                string lck = BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK);
                if (key != lck)
                {
                    return(true);
                }



                if (OfflineBookingId < 1)
                {
                    return(false);
                }
                CLayer.OfflineBooking Offlinedata         = BLayer.OfflineBooking.GetAllDetailsById(OfflineBookingId);
                CLayer.OfflineBooking OfflinePropertydata = BLayer.OfflineBooking.GetAllpropertyDetails(OfflineBookingId);
                CLayer.OfflineBooking CustomerDetails     = BLayer.OfflineBooking.GetAllCustomerDetails(OfflineBookingId);

                if (CustomerDetails == null)
                {
                    return(false);
                }
                if (OfflinePropertydata == null)
                {
                    return(false);
                }

                CLayer.StayCategory      Staycategorydetails      = BLayer.StayCategory.Get(Convert.ToInt32(Offlinedata.StayCategoryid));
                CLayer.AccommodationType AccommodationTypedetails = BLayer.AccommodationType.Get(Convert.ToInt32(Offlinedata.Accommodationtypeid));

                CLayer.Role.Roles rle = BLayer.User.GetRole(Offlinedata.CustomerId);

                string        message = "";
                Common.Mailer ml      = new Common.Mailer();

                if (OfflineBookingId < 1)
                {
                    return(false);
                }
                try
                {
                    if (OfflinePropertydata.PropertyEmail != "")
                    {
                        message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupplierIntemationOfflineBookGST") + OfflineBookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK) + "&BookingDetailsId=" + BookingDetailsId);

                        System.Net.Mail.MailMessage supplierMsg = new System.Net.Mail.MailMessage();

                        string BccEmailsforsupp = BLayer.Settings.GetValue(CLayer.Settings.CC_SUPPLIERCOMMUNICATION);
                        if (BccEmailsforsupp != "")
                        {
                            string[] emails = BccEmailsforsupp.Split(',');
                            for (int i = 0; i < emails.Length; ++i)
                            {
                                supplierMsg.Bcc.Add(emails[i]);
                            }
                        }

                        supplierMsg.Subject = "Booking Confirmation";
                        supplierMsg.Body    = message;

                        if (OfflinePropertydata.PropertyEmail != "")
                        {
                            supplierMsg.To.Add(OfflinePropertydata.PropertyEmail);
                        }
                        supplierMsg.IsBodyHtml = true;

                        try
                        {
                            await ml.SendMailAsync(supplierMsg, Common.Mailer.MailType.Reservation);
                        }
                        catch (Exception ex)
                        {
                            Common.LogHandler.HandleError(ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Beispiel #13
0
        public static List <CLayer.Rates> GetTotalRates(List <long> accIds, DateTime checkIn, DateTime checkOut, CLayer.Role.Roles rateType, long loggedInUserId, long InventoryAPIID)
        {
            List <CLayer.Rates> arates;
            StringBuilder       ids = new StringBuilder();
            bool isCorporate        = false;
            long TAMInventoryAPIID  = InventoryAPIID;
            long corpId             = 0;

            if (rateType == CLayer.Role.Roles.Corporate)
            {
                CLayer.Role.Roles rle = BLayer.User.GetRole(loggedInUserId);
                if (rle == CLayer.Role.Roles.CorporateUser)
                {
                    corpId = BLayer.B2B.GetCorporateIdOfUser(loggedInUserId);
                }
                else
                {
                    corpId = loggedInUserId;
                }
                isCorporate = true;
            }


            foreach (long id in accIds)
            {
                ids.Append(",");
                ids.Append(id);
            }
            ids.Remove(0, 1);

            List <CLayer.Rates> result = new List <CLayer.Rates>();

            if (TAMInventoryAPIID == 4 || TAMInventoryAPIID == 5)
            {
                arates = GetAccommodationRatesForAPI(ids.ToString(), checkIn, checkOut, rateType);
            }
            else
            {
                arates = GetAccommodationRates(ids.ToString(), checkIn, checkOut, rateType);
            }

            DateTime currentDate;
            decimal  total, currate, curguest_rate, guest, PurchaseRateaAfterTaxs, totalPurchaseRateAfterTaxs, PurchaseRateBeforeTax, SellRateAfterTax, SellRateBeforeTax, Prch_Rate_AT, Prch_Rate_ATX, PurchaseRateAfterTax;

            int  cnt, idx;
            int  days       = (checkOut - checkIn).Days;
            long propertyId = BLayer.Accommodation.GetPropertyId(accIds[0]);
            int  inventory  = 0;

            CLayer.Discount dicnt = null;

            if (isCorporate)
            {
                dicnt = BLayer.Discount.GetDiscount(corpId, propertyId);
            }

            CLayer.RateCommission rc = BLayer.Property.GetCommission(propertyId);


            List <CLayer.Offers> propertyOffers = BLayer.Offers.GetForPropertyCalc(propertyId, checkIn, checkOut);
            bool hasPrOffers = (propertyOffers.Count > 0);
            List <CLayer.Offers> accOffers;

            CLayer.Offers propOffer = null;
            if (hasPrOffers)
            {
                propOffer = propertyOffers[0];
            }
            CLayer.Offers curOffer = null;
            DateTime      offEndDate, offStartDate;

            offStartDate = offEndDate = DateTime.Today;

            List <CLayer.BookingItemOffer> appliedOffers;
            List <CLayer.Rates.RateValues> bookingRates;

            int noOfDays     = (checkOut - checkIn).Days;
            int reduceDateBy = 0;
            int calcDays     = 0;

            long            curOfferId    = 0;
            decimal         curOldRate    = 0;
            List <DateTime> freeDays      = new List <DateTime>();
            bool            freeDaysExist = false;

            foreach (long id in accIds)
            {
                List <CLayer.Rates> accrates = arates.Where(m => m.AccommodationId == id).OrderBy(x => x.StartDate).ToList();
                cnt = accrates.Count();
                if (cnt > 0)
                {
                    inventory = accrates[0].NoofAcc;
                }
                else
                {
                    inventory = 0;
                    result.Add(new CLayer.Rates()
                    {
                        Amount          = 0,
                        GuestRate       = 0,
                        AccommodationId = id,
                        NoofAcc         = 0,
                        RateChanges     = new List <CLayer.Rates.RateValues>(), //FirstDayCharge = fctotal,
                        SBMarkup        = 0,
                        CorpDiscount    = 0,
                        AppliedOffers   = new List <CLayer.BookingItemOffer>()
                    });
                    continue;
                }
                accOffers     = BLayer.Offers.GetForAccommodationCalc(id, checkIn, checkOut);
                appliedOffers = new List <CLayer.BookingItemOffer>();
                curOffer      = null;
                bookingRates  = new List <CLayer.Rates.RateValues>();
                if (accOffers.Count > 0)
                {
                    curOffer = accOffers[0];
                }
                else
                {
                    curOffer = null;
                    if (hasPrOffers)
                    {
                        curOffer = propOffer;
                    }
                }
                curOfferId                 = 0;
                currentDate                = checkIn;
                total                      = 0;
                guest                      = 0;
                PurchaseRateaAfterTaxs     = 0;
                totalPurchaseRateAfterTaxs = 0;
                currate                    = 0;
                curOldRate                 = 0;
                curguest_rate              = 0;
                SellRateBeforeTax          = 0;
                PurchaseRateBeforeTax      = 0;
                Prch_Rate_AT               = 0;
                Prch_Rate_ATX              = 0;
                PurchaseRateAfterTax       = 0;
                SellRateAfterTax           = 0;
                freeDays.Clear();
                //calculate if free nights offer is available..
                reduceDateBy = 0;

                if (curOffer != null && (!isCorporate)) //offer is not available for corporate
                {
                    //find offer applicable date
                    if (checkIn > curOffer.StartDate)
                    {
                        offStartDate = checkIn;
                    }
                    else
                    {
                        offStartDate = curOffer.StartDate;
                    }
                    if (checkOut < curOffer.EndDate)
                    {
                        offEndDate = checkOut;
                    }
                    else
                    {
                        offEndDate = curOffer.EndDate;
                    }


                    if (curOffer.RateType == (int)CLayer.ObjectStatus.OfferRateType.OfferFreeRate)
                    {
                        int tot    = curOffer.FreeDays + curOffer.NoOfDays; //total days -Example:  for 4 days booking 2 days free.. So total - minimum- 6days booking should be there
                        int hwmany = 0;
                        calcDays = (offEndDate - offStartDate).Days;
                        if (calcDays >= tot)
                        {
                            hwmany       = calcDays / tot;
                            reduceDateBy = hwmany * curOffer.FreeDays;
                            //  currentDate = currentDate.AddDays(reduceDateBy); //reduce freedays from calculation

                            if (reduceDateBy == 1)
                            {
                                if (offEndDate == checkOut)
                                {
                                    offEndDate = offEndDate.AddDays(-1);
                                }
                                if (offEndDate >= checkIn)
                                {
                                    freeDays.Add(offEndDate);
                                }
                            }
                            else if (reduceDateBy > 1)
                            {
                                if (offEndDate == checkOut)
                                {
                                    offEndDate = offEndDate.AddDays(-1);
                                }
                                while (reduceDateBy > 0)
                                {
                                    if (offEndDate >= checkIn)
                                    {
                                        freeDays.Add(offEndDate);
                                    }
                                    offEndDate.AddDays(-1 * reduceDateBy);
                                    reduceDateBy--;
                                }
                            }
                            //to do offer applied markit
                            curOfferId = curOffer.OfferId;
                            appliedOffers.Add(new CLayer.BookingItemOffer()
                            {
                                OfferId = curOffer.OfferId, OfferTitle = curOffer.Title, AccommodationId = id
                            });
                        }
                        curOffer = null; //avoid checking other offer types
                    }
                }
                freeDaysExist = (freeDays.Count > 0);

                // find tax here

                decimal tax = BLayer.PropertyTax.GetTotalTax(propertyId);

                while (currentDate < checkOut)
                {
                    //never reset currate or curguest_rate here, if a rate is not found for the date then old rate is used
                    for (idx = 0; idx < cnt; idx++)
                    {
                        if (currentDate >= accrates[idx].StartDate && currentDate <= accrates[idx].EndDate)
                        {
                            currate                = accrates[idx].Amount;
                            curguest_rate          = accrates[idx].GuestRate;
                            PurchaseRateaAfterTaxs = accrates[idx].PurchaseRateAfterTax;
                            Prch_Rate_AT           = accrates[idx].PurchaseRateAfterTax;
                            break;
                        }
                    }
                    if (curOldRate != currate)
                    {
                        bookingRates.Add(new CLayer.Rates.RateValues()
                        {
                            StartDate = currentDate.ToShortDateString(), DayCharge = (double)currate, DayGuestCharge = (double)curguest_rate, DayTotalCharge = 0, DayTotalGuestCharge = 0
                        });
                        curOldRate = currate;
                    }
                    if (curOffer != null && (!isCorporate))
                    {
                        if (currentDate >= offStartDate && currentDate <= offEndDate)
                        {
                            if (curOfferId != curOffer.OfferId && curOfferId != 0)
                            {
                                curOfferId = curOffer.OfferId;
                                appliedOffers.Add(new CLayer.BookingItemOffer()
                                {
                                    OfferId = curOffer.OfferId, OfferTitle = curOffer.Title, AccommodationId = id
                                });
                            }

                            switch ((CLayer.ObjectStatus.OfferRateType)curOffer.RateType)
                            {
                            case CLayer.ObjectStatus.OfferRateType.OfferFlatRate:
                                total = total + curOffer.Amount;
                                guest = guest + curguest_rate;
                                break;

                            case CLayer.ObjectStatus.OfferRateType.OfferPercentageRate:
                                total = Math.Round(total + (currate - (currate * curOffer.Amount / 100)));
                                guest = Math.Round(guest + (curguest_rate - (curguest_rate * curOffer.Amount / 100)));
                                break;
                            }
                        }
                        else
                        {
                            total = total + currate;
                            totalPurchaseRateAfterTaxs = totalPurchaseRateAfterTaxs + PurchaseRateaAfterTaxs;
                            guest         = guest + curguest_rate;
                            Prch_Rate_ATX = Prch_Rate_ATX + Prch_Rate_AT;
                        }
                    }
                    else
                    {
                        //perform calculations here
                        if (freeDaysExist)
                        {
                            if (!freeDays.Contains(currentDate))
                            {
                                total = total + currate;
                                totalPurchaseRateAfterTaxs = totalPurchaseRateAfterTaxs + PurchaseRateaAfterTaxs;
                                guest         = guest + curguest_rate;
                                Prch_Rate_ATX = Prch_Rate_ATX + Prch_Rate_AT;
                            }
                        }
                        else
                        {
                            total = total + currate;
                            totalPurchaseRateAfterTaxs = totalPurchaseRateAfterTaxs + PurchaseRateaAfterTaxs;
                            guest         = guest + curguest_rate;
                            Prch_Rate_ATX = Prch_Rate_ATX + Prch_Rate_AT;
                        }
                    }
                    currentDate = currentDate.AddDays(1);
                }

                decimal CalcTotalTax = Math.Round((total * tax) / 100);
                decimal CalcGuestTax = Math.Round((guest * tax) / 100);

                //reduce tax from supplier rate
                SellRateAfterTax           = total;
                total                      = Math.Round(total / (1 + (tax / 100)));
                guest                      = Math.Round(guest / (1 + (tax / 100)));
                totalPurchaseRateAfterTaxs = Math.Round(totalPurchaseRateAfterTaxs / (1 + (tax / 100)));
                SellRateBeforeTax          = totalPurchaseRateAfterTaxs;
                PurchaseRateBeforeTax      = total;
                PurchaseRateAfterTax       = Prch_Rate_ATX;

                //calculate corp discount and SB Markup here..


                //SB Markup
                decimal SBMarkup_rate  = 0;
                decimal SBMarkup_guest = 0;

                if (days < CLayer.Rates.LONG_TERM_DAYS)
                {
                    if (isCorporate)
                    {
                        SBMarkup_rate  = Math.Round(total * ((decimal)rc.B2BShortTerm) / 100);
                        SBMarkup_guest = Math.Round(guest * ((decimal)rc.B2BShortTerm) / 100);
                        //first day charge
                        //diff rates calculation
                        for (int ai = 0; ai < bookingRates.Count; ai++)
                        {
                            bookingRates[ai].DayTotalCharge      = bookingRates[ai].DayCharge + Math.Round(bookingRates[ai].DayCharge * rc.B2BShortTerm / 100);
                            bookingRates[ai].DayTotalGuestCharge = bookingRates[ai].DayGuestCharge + Math.Round(bookingRates[ai].DayGuestCharge * rc.B2BShortTerm / 100);
                        }
                    }
                    else
                    {
                        if (TAMInventoryAPIID == 4 || TAMInventoryAPIID == 5)
                        {
                            SBMarkup_rate  = Math.Round(total - totalPurchaseRateAfterTaxs);
                            SBMarkup_guest = Math.Round(guest * ((decimal)rc.B2CShortTerm) / 100);
                        }
                        else
                        {
                            SBMarkup_rate  = Math.Round(total * ((decimal)rc.B2CShortTerm) / 100);
                            SBMarkup_guest = Math.Round(guest * ((decimal)rc.B2CShortTerm) / 100);
                        }
                        ////first day charge
                        for (int ai = 0; ai < bookingRates.Count; ai++)
                        {
                            bookingRates[ai].DayTotalCharge      = bookingRates[ai].DayCharge + Math.Round(bookingRates[ai].DayCharge * rc.B2CShortTerm / 100);
                            bookingRates[ai].DayTotalGuestCharge = bookingRates[ai].DayGuestCharge + Math.Round(bookingRates[ai].DayGuestCharge * rc.B2CShortTerm / 100);
                        }
                    }
                }
                else
                {
                    if (isCorporate)
                    {
                        SBMarkup_rate  = Math.Round(total * ((decimal)rc.B2BLongTerm) / 100);
                        SBMarkup_guest = Math.Round(guest * ((decimal)rc.B2BLongTerm) / 100);
                        //first day charge
                        //diff rates calc
                        for (int ai = 0; ai < bookingRates.Count; ai++)
                        {
                            bookingRates[ai].DayTotalCharge      = bookingRates[ai].DayTotalCharge + Math.Round(bookingRates[ai].DayCharge * rc.B2BLongTerm / 100);
                            bookingRates[ai].DayTotalGuestCharge = bookingRates[ai].DayTotalGuestCharge + Math.Round(bookingRates[ai].DayGuestCharge * rc.B2BLongTerm / 100);
                        }
                    }
                    else
                    {
                        if (TAMInventoryAPIID == 4 || TAMInventoryAPIID == 5)
                        {
                            SBMarkup_rate  = Math.Round(total - totalPurchaseRateAfterTaxs);
                            SBMarkup_guest = Math.Round(guest * ((decimal)rc.B2CLongTerm) / 100);
                        }
                        else
                        {
                            SBMarkup_rate  = Math.Round(total * ((decimal)rc.B2CLongTerm) / 100);
                            SBMarkup_guest = Math.Round(guest * ((decimal)rc.B2CLongTerm) / 100);
                        }

                        //diff rates calc
                        for (int ai = 0; ai < bookingRates.Count; ai++)
                        {
                            bookingRates[ai].DayTotalCharge      = bookingRates[ai].DayTotalCharge + Math.Round(bookingRates[ai].DayCharge * rc.B2CLongTerm / 100);
                            bookingRates[ai].DayTotalGuestCharge = bookingRates[ai].DayTotalGuestCharge + Math.Round(bookingRates[ai].DayGuestCharge * rc.B2CLongTerm / 100);
                        }
                    }
                }
                //Corporate Discount
                decimal add_discount  = 0;
                decimal base_discount = 0;

                decimal guest_add_discount  = 0;
                decimal guest_base_discount = 0;

                if (isCorporate)
                {
                    if (days < CLayer.Rates.LONG_TERM_DAYS)
                    {
                        if (dicnt.ShortTermRate > 0)
                        {
                            add_discount       = Math.Round(total * (decimal)dicnt.ShortTermRate / 100);
                            guest_add_discount = Math.Round(guest * (decimal)dicnt.ShortTermRate / 100);
                            //first day charge
                            //individual rates
                            for (int ai = 0; ai < bookingRates.Count; ai++)
                            {
                                bookingRates[ai].DayTotalCharge      = bookingRates[ai].DayTotalCharge - Math.Round(bookingRates[ai].DayCharge * dicnt.ShortTermRate / 100);
                                bookingRates[ai].DayTotalGuestCharge = bookingRates[ai].DayTotalGuestCharge - Math.Round(bookingRates[ai].DayGuestCharge * dicnt.ShortTermRate / 100);
                            }
                        }

                        if (dicnt.BaseShortTerm > 0)
                        {
                            base_discount       = Math.Round(total * (decimal)dicnt.BaseShortTerm / 100);
                            guest_base_discount = Math.Round(guest * (decimal)dicnt.BaseShortTerm / 100);
                            //first day charge
                            for (int ai = 0; ai < bookingRates.Count; ai++)
                            {
                                bookingRates[ai].DayTotalCharge      = bookingRates[ai].DayTotalCharge - Math.Round(bookingRates[ai].DayCharge * dicnt.BaseShortTerm / 100, 2);
                                bookingRates[ai].DayTotalGuestCharge = bookingRates[ai].DayTotalGuestCharge - Math.Round(bookingRates[ai].DayGuestCharge * dicnt.BaseShortTerm / 100, 2);
                            }
                        }
                    }
                    else
                    {
                        if (dicnt.LongTermRate > 0)
                        {
                            add_discount       = Math.Round(total * (decimal)dicnt.LongTermRate / 100);
                            guest_add_discount = Math.Round(guest * (decimal)dicnt.LongTermRate / 100);
                            //first day charge
                            //diff rates calc
                            for (int ai = 0; ai < bookingRates.Count; ai++)
                            {
                                bookingRates[ai].DayTotalCharge      = bookingRates[ai].DayTotalCharge - Math.Round(bookingRates[ai].DayCharge * dicnt.LongTermRate / 100);
                                bookingRates[ai].DayTotalGuestCharge = bookingRates[ai].DayTotalGuestCharge - Math.Round(bookingRates[ai].DayGuestCharge * dicnt.LongTermRate / 100);
                            }
                        }
                        if (dicnt.BaseLongTerm > 0)
                        {
                            base_discount      = Math.Round(total * (decimal)dicnt.BaseLongTerm / 100);
                            guest_add_discount = Math.Round(guest * (decimal)dicnt.BaseLongTerm / 100);
                            //first day charge
                            //diff rates calc
                            for (int ai = 0; ai < bookingRates.Count; ai++)
                            {
                                bookingRates[ai].DayTotalCharge      = bookingRates[ai].DayTotalCharge - Math.Round(bookingRates[ai].DayCharge * dicnt.BaseLongTerm / 100);
                                bookingRates[ai].DayTotalGuestCharge = bookingRates[ai].DayTotalGuestCharge - Math.Round(bookingRates[ai].DayGuestCharge * dicnt.BaseLongTerm / 100);
                            }
                        }
                    }
                }
                decimal suppRate      = total;
                decimal suppGuestRate = guest;


                if (TAMInventoryAPIID == 4 || TAMInventoryAPIID == 5)
                {
                    total = Math.Round(total);
                    guest = Math.Round(guest + SBMarkup_guest - guest_add_discount - guest_base_discount);
                }
                else
                {
                    total = Math.Round(total + SBMarkup_rate - add_discount - base_discount);
                    guest = Math.Round(guest + SBMarkup_guest - guest_add_discount - guest_base_discount);
                }


                //find tax on total amount and guest rate

                decimal totaltax = (total * tax) / 100;
                decimal guesttax = (guest * tax) / 100;

                result.Add(new CLayer.Rates()
                {
                    SupplierRate          = suppRate + CalcTotalTax,
                    SupplierGuestRate     = guest + CalcGuestTax,
                    Amount                = total,
                    GuestRate             = guest,
                    AccommodationId       = id,
                    NoofAcc               = inventory,
                    RateChanges           = bookingRates,  //FirstDayCharge = fctotal,
                    SBMarkup              = SBMarkup_rate, //(SBMarkup_rate + SBMarkup_guest),
                    SBGuestMarkup         = SBMarkup_guest,
                    CorpDiscount          = (add_discount + base_discount),
                    CorpGuestDiscount     = (guest_add_discount + guest_base_discount),
                    AppliedOffers         = appliedOffers,
                    TotalRateTax          = totaltax,
                    TotalGuestTax         = guesttax,
                    PurchaseRateAfterTax  = PurchaseRateAfterTax,
                    SellRateBeforeTax     = PurchaseRateBeforeTax,
                    PurchaseRateBeforeTax = SellRateBeforeTax,
                    SellRateAfterTax      = SellRateAfterTax
                });
            }
            return(result);
        }
Beispiel #14
0
 //**Added by rahul on 04/03/2020
 //*This is for getting rates for property Accommodation for API
 public static List <CLayer.Rates> GetAccommodationRatesForAPI(string AccIds, DateTime checkIn, DateTime checkOut, CLayer.Role.Roles rateType)
 {
     DataLayer.Rate dr = new DataLayer.Rate();
     return(dr.GetAccommodationRatesForAPI(AccIds, checkIn, checkOut, (checkOut - checkIn).Days, rateType, CLayer.Role.Roles.Customer));
 }
Beispiel #15
0
        public async Task <bool> ResendemailC(long OfflineBookingId)
        {
            return(true);

            try
            {
                if (OfflineBookingId < 1)
                {
                    return(false);
                }
                CLayer.OfflineBooking Offlinedata         = BLayer.OfflineBooking.GetAllDetailsById(OfflineBookingId);
                CLayer.OfflineBooking OfflinePropertydata = BLayer.OfflineBooking.GetAllpropertyDetails(OfflineBookingId);
                CLayer.OfflineBooking CustomerDetails     = BLayer.OfflineBooking.GetAllCustomerDetails(OfflineBookingId);

                if (CustomerDetails == null)
                {
                    return(false);
                }
                if (OfflinePropertydata == null)
                {
                    return(false);
                }

                CLayer.StayCategory      Staycategorydetails      = BLayer.StayCategory.Get(Convert.ToInt32(Offlinedata.StayCategoryid));
                CLayer.AccommodationType AccommodationTypedetails = BLayer.AccommodationType.Get(Convert.ToInt32(Offlinedata.Accommodationtypeid));

                CLayer.Role.Roles rle = BLayer.User.GetRole(Offlinedata.CustomerId);

                string        message = "";
                Common.Mailer ml      = new Common.Mailer();

                string link = System.Configuration.ConfigurationManager.AppSettings.Get("OfflineBookingConfirmation") + OfflineBookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK);
                //for normal user mail body
                message = await Common.Mailer.MessageFromHtml(link);

                System.Net.Mail.MailMessage customerMsg = new System.Net.Mail.MailMessage();
                //guest mail added
                customerMsg.To.Add(CustomerDetails.CustomerEmail);

                string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                if (BccEmailsforcususer != "")
                {
                    string[] emails = BccEmailsforcususer.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        customerMsg.Bcc.Add(emails[i]);
                    }
                }
                customerMsg.Subject = "Booking Confirmation";
                customerMsg.Body    = message;

                customerMsg.IsBodyHtml = true;
                try
                {
                    await ml.SendMailAsync(customerMsg, Common.Mailer.MailType.Reservation);
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
        public RedirectResult SaveOfflinePaybyPaypal(Models.OfflinePaymentModel data)
        {
            string errorPage = System.Configuration.ConfigurationManager.AppSettings.Get(PAYMENT_FAILED_LINK);

            try
            {
                long UserId = GetUserId();
                CLayer.OfflinePayment dt = new CLayer.OfflinePayment();
                dt.Name            = data.Name;
                dt.Amount          = data.Amount;
                dt.ReferenceNumber = data.ReferenceNumber;
                dt.Message         = data.Message;
                dt.UserId          = UserId;
                dt.Address         = data.Address;
                dt.CountryId       = data.CountryId;
                dt.StateId         = data.State;
                dt.CityId          = data.CityId;
                if (data.City != null && data.City != "")
                {
                    dt.City = data.City;
                }
                if (data.CityId > 0)
                {
                    dt.City = BLayer.City.Get(data.CityId).Name;
                }
                dt.Email       = data.Email;
                dt.Mobile      = data.Mobile;
                dt.ZipCode     = data.ZipCode;
                dt.Gatewaytype = (int)CLayer.ObjectStatus.Gateway.PayPal;
                CLayer.Role.Roles rle   = BLayer.User.GetRole(UserId);
                long   OfflinePaymentId = BLayer.OfflinePayment.SaveInitialPaymentData(dt);
                string PaymentRefNo     = " ";

                string token = "";

                try
                {
                    //load paypal url from settings
                    string     url  = BLayer.Settings.GetValue(CLayer.Settings.PAYPAL_TOKEN_URL);
                    WebRequest rqst = HttpWebRequest.Create(url);

                    rqst.Method = "POST";
                    string user, pwd, signature, returnurl, cancelurl;
                    user      = BLayer.Settings.GetValue(CLayer.Settings.PAYPAL_USER);
                    pwd       = BLayer.Settings.GetValue(CLayer.Settings.PAYPAL_PWD);
                    signature = BLayer.Settings.GetValue(CLayer.Settings.PAYPAL_SIGNAUTRE);
                    returnurl = BLayer.Settings.GetValue(CLayer.Settings.OFFLINE_PAYPAL_RETURN_URL);
                    cancelurl = BLayer.Settings.GetValue(CLayer.Settings.PAYPAL_CANCELURL);

                    CLayer.Currency cur = BLayer.Currency.Get("USD");
                    if (cur == null)
                    {
                        throw new Exception("Cannot find USD conversion rate for Paypal booking");
                    }
                    decimal amount = data.Amount;
                    amount = Math.Round(amount * cur.ConversionRate, 2, MidpointRounding.AwayFromZero);

                    string ProBookDes = data.Message;
                    string postdata   = "METHOD=SetExpressCheckout&VERSION=109.0";
                    postdata = postdata + "&USER="******"&PWD=" + pwd + "&SIGNATURE=" + signature;
                    postdata = postdata + "&PAYMENTREQUEST_0_AMT=" + amount.ToString("F2") + "&PAYMENTREQUEST_0_CURRENCYCODE=USD" + "&PAYMENTREQUEST_0_DESC=" + ProBookDes;
                    postdata = postdata + "&RETURNURL=" + Server.UrlEncode(returnurl);
                    postdata = postdata + "&CANCELURL=" + Server.UrlEncode(cancelurl);
                    postdata = postdata + "&PAYMENTREQUEST_0_PAYMENTACTION=Sale";

                    if (!String.IsNullOrEmpty(postdata))
                    {
                        rqst.ContentType = "application/x-www-form-urlencoded";
                        byte[] byteData = UTF8Encoding.UTF8.GetBytes(postdata);
                        rqst.ContentLength = byteData.Length;
                        using (Stream postStream = rqst.GetRequestStream())
                        {
                            postStream.Write(byteData, 0, byteData.Length);
                            postStream.Close();
                        }
                    }
                    ((HttpWebRequest)rqst).KeepAlive = false;
                    StreamReader rsps    = new StreamReader(rqst.GetResponse().GetResponseStream());
                    string       strRsps = rsps.ReadToEnd();
                    Debug.WriteLine(strRsps);
                    token = PaymentController.GetToken(strRsps);
                    if (token == "")
                    {
                        //(int)CLayer.ObjectStatus.OfflinePyamentStatus.Processing
                        BLayer.OfflinePayment.SetStatus((int)CLayer.ObjectStatus.OfflinePyamentStatus.failed, OfflinePaymentId);
                        return(Redirect(errorPage));
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                    BLayer.OfflinePayment.SetStatus((int)CLayer.ObjectStatus.OfflinePyamentStatus.failed, OfflinePaymentId);
                    return(Redirect(errorPage));
                }

                string red = BLayer.Settings.GetValue(CLayer.Settings.PAYPAL_REQUEST_URL) + token;

                token = Server.UrlDecode(token);
                //save to database
                PaymentRefNo = token;
                long OffPayId = BLayer.OfflinePayment.SetPaymentRefNo(OfflinePaymentId, rle, PaymentRefNo);
                BLayer.OfflinePayment.SetStatus((int)CLayer.ObjectStatus.OfflinePyamentStatus.Processing, OfflinePaymentId);
                return(Redirect(red));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect(errorPage));
            }
        }
Beispiel #17
0
        //RESEND EMAIL
        public async Task <bool> ResendemailC(long bookingId)
        {
            //send customer email/message
            //email
            if (bookingId < 1)
            {
                return(false);
            }
            CLayer.Address        byUser  = BLayer.Bookings.GetBookedByUser(bookingId);
            List <CLayer.Address> forUser = BLayer.Bookings.GetBookedForUser(bookingId);

            CLayer.Booking details  = BLayer.Bookings.GetDetailsSMS(bookingId);
            CLayer.User    supplier = BLayer.Bookings.GetSupplierDetails(bookingId);
            if (byUser == null)
            {
                return(false);
            }
            if (forUser.Count == 0)
            {
                return(false);
            }
            CLayer.Role.Roles rle = BLayer.User.GetRole(byUser.UserId);
            try
            {
                string        message = "";
                Common.Mailer ml      = new Common.Mailer();
                message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("Bofflinebookconfirm") + bookingId.ToString());

                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                //guest mail added
                msg.To.Add(forUser[0].Email);
                if (forUser[0].Email != byUser.Email)
                {
                    msg.CC.Add(byUser.Email);
                }

                string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                if (BccEmailsforcususer != "")
                {
                    string[] emails = BccEmailsforcususer.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        msg.Bcc.Add(emails[i]);
                    }
                }
                msg.Subject = "Booking Payment";
                msg.Body    = message;

                msg.IsBodyHtml = true;

                try
                {
                    await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Beispiel #18
0
        //Confirm Booking
        public async Task <bool> BookingConfirm(long bookingId)
        {
            try
            {
                BLayer.Bookings.SetStatus((int)CLayer.ObjectStatus.BookingStatus.offlineconfirm, bookingId);

                //send customer email/message
                //email
                if (bookingId < 1)
                {
                    return(false);
                }
                CLayer.Address        byUser   = BLayer.Bookings.GetBookedByUser(bookingId);
                List <CLayer.Address> forUser  = BLayer.Bookings.GetBookedForUser(bookingId);
                CLayer.Booking        details  = BLayer.Bookings.GetDetailsSMS(bookingId);
                CLayer.User           supplier = BLayer.Bookings.GetSupplierDetails(bookingId);
                if (byUser == null)
                {
                    return(false);
                }
                if (forUser.Count == 0)
                {
                    return(false);
                }
                CLayer.Role.Roles rle = BLayer.User.GetRole(byUser.UserId);
                try
                {
                    string        message = "";
                    Common.Mailer ml      = new Common.Mailer();
                    //for normal user mail body
                    //message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("Bofflinebookconfirm") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));
                    message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("Bofflinebookconfirm") + bookingId.ToString());

                    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                    //guest mail added
                    msg.To.Add(forUser[0].Email);
                    if (forUser[0].Email != byUser.Email)
                    {
                        msg.CC.Add(byUser.Email);
                    }

                    string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                    if (BccEmailsforcususer != "")
                    {
                        string[] emails = BccEmailsforcususer.Split(',');
                        for (int i = 0; i < emails.Length; ++i)
                        {
                            msg.Bcc.Add(emails[i]);
                        }
                    }

                    //for corporate admins
                    if (rle == CLayer.Role.Roles.CorporateUser)
                    {
                        long cid = BLayer.B2B.GetCorporateIdOfUser(byUser.UserId);
                        if (cid > 0)
                        {
                            string em = BLayer.User.GetEmail(cid);
                            if (em != null && em != "")
                            {
                                msg.CC.Add(em);
                            }
                        }
                    }
                    msg.Subject = "Booking Payment";
                    msg.Body    = message;

                    msg.IsBodyHtml = true;

                    try
                    {
                        await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }

                    //message
                    //if (bookingId < 1) return false;
                    //if (byUser == null) return false;
                    //if (forUser.Count == 0) return false;
                    //try
                    //{
                    //    string phone = forUser[0].Mobile;
                    //    if (phone == "") phone = forUser[0].Phone;
                    //    string smsmsg = Common.SMSGateway.GetNewBookingMessage(forUser[0].Firstname + " " + forUser[0].Lastname, details.OrderNo, details.CheckIn.ToString("MMM dd,yyyy"),
                    //        details.CheckOut.ToString("MMM dd,yyyy"), details.PropertyTitle, details.propertyCity, details.AccommodationTypeTitle, BLayer.Settings.GetValue(CLayer.Settings.STAYB_CONTACTNO));
                    //    bool b = false;
                    //    phone = Common.Utils.GetMobileNo(phone);

                    //    if (phone != "")
                    //    {
                    //        b = await Common.SMSGateway.Send(smsmsg, phone);
                    //    }
                    //}
                    //catch (Exception ex)
                    //{
                    //    Common.LogHandler.HandleError(ex);
                    //}

                    //send supplier email/message
                    //message
                    //if (bookingId < 1) return false;
                    //if (byUser == null) return false;
                    //if (forUser.Count == 0) return false;
                    //try
                    //{
                    //    string phone = forUser[0].Mobile;
                    //    if (phone == "") phone = forUser[0].Phone;
                    //    string smsmsg = Common.SMSGateway.GetNewBookingMessage(forUser[0].Firstname + " " + forUser[0].Lastname, details.OrderNo, details.CheckIn.ToString("MMM dd,yyyy"),
                    //        details.CheckOut.ToString("MMM dd,yyyy"), details.PropertyTitle, details.propertyCity, details.AccommodationTypeTitle, BLayer.Settings.GetValue(CLayer.Settings.STAYB_CONTACTNO));
                    //    bool b = false;
                    //    phone = Common.Utils.GetMobileNo(phone);

                    //    if (phone != "")
                    //    {
                    //        b = await Common.SMSGateway.Send(smsmsg, phone);
                    //    }
                    //}
                    //catch (Exception ex)
                    //{
                    //    Common.LogHandler.HandleError(ex);
                    //}

                    //email
                    //if (bookingId < 1) return false;
                    //try
                    //{
                    //    if (supplier.Email != "" || details.PropertyEmail != "")
                    //    {
                    //        if (supplier.Email == "")
                    //        {
                    //            supplier.Email = details.PropertyEmail;
                    //            details.PropertyEmail = "";
                    //        }
                    //        //   message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupplierIntimation") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));
                    //        message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("SupplierIntimation") + bookingId.ToString());
                    //        System.Net.Mail.MailMessage supplierMsg = new System.Net.Mail.MailMessage();
                    //        supplierMsg.To.Add(supplier.Email);
                    //        supplierMsg.Subject = "Booking Confirmation";
                    //        supplierMsg.Body = message;

                    //        string BccEmailsforsupp = BLayer.Settings.GetValue("CCSuppliercommunications ");
                    //        if (BccEmailsforsupp != "")
                    //        {
                    //            string[] emails = BccEmailsforsupp.Split(',');
                    //            for (int i = 0; i < emails.Length; ++i)
                    //            {
                    //                supplierMsg.Bcc.Add(emails[i]);
                    //            }
                    //        }


                    //        if (details.PropertyEmail != "") supplierMsg.To.Add(details.PropertyEmail);
                    //        supplierMsg.IsBodyHtml = true;

                    //        try
                    //        {
                    //            await ml.SendMailAsync(supplierMsg, Common.Mailer.MailType.Reservation);
                    //        }
                    //        catch (Exception ex)
                    //        {
                    //            Common.LogHandler.HandleError(ex);
                    //        }

                    //    }

                    //}
                    //catch (Exception ex)
                    //{
                    //    Common.LogHandler.HandleError(ex);
                    //}
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
        //RESEND EMAIL
        public async Task <bool> ResendemailC(long bookingId)
        {
            try
            {
                if (bookingId < 1)
                {
                    return(false);
                }
                CLayer.Address        byUser  = BLayer.Bookings.GetBookedByUser(bookingId);
                List <CLayer.Address> forUser = BLayer.Bookings.GetBookedForUser(bookingId);
                if (byUser == null)
                {
                    return(false);
                }
                if (forUser.Count == 0)
                {
                    return(false);
                }
                CLayer.Role.Roles rle = BLayer.User.GetRole(byUser.UserId);
                try
                {
                    string        message = "";
                    Common.Mailer ml      = new Common.Mailer();
                    //for normal user mail body
                    message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("BConfirmationMail") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));

                    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                    //guest mail added
                    msg.To.Add(forUser[0].Email);
                    if (forUser[0].Email != byUser.Email)
                    {
                        msg.CC.Add(byUser.Email);
                    }
                    //for corporate admins
                    if (rle == CLayer.Role.Roles.CorporateUser)
                    {
                        //  message = await Common.Mailer.MessageFromHtml(System.Configuration.ConfigurationManager.AppSettings.Get("CorpIntimation") + bookingId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK));
                        long cid = BLayer.B2B.GetCorporateIdOfUser(byUser.UserId);
                        if (cid > 0)
                        {
                            string em = BLayer.User.GetEmail(cid);
                            if (em != null && em != "")
                            {
                                msg.CC.Add(em);
                            }
                        }
                    }
                    msg.Subject = "Booking Confirmation";
                    msg.Body    = message;

                    msg.IsBodyHtml = true;
                    try
                    {
                        await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Beispiel #20
0
        public static int BookAccommodations(List <CLayer.BookingAccDetails> bookingInfo, DateTime checkIn, DateTime checkOut, long userId, long bookingId, string orderNo = "")
        {
            long        PropId           = BLayer.Accommodation.GetPropertyId(bookingInfo[0].AccommodationId);
            decimal     tax              = BLayer.PropertyTax.GetTotalTax(PropId);
            long        InventoryAPIType = BLayer.Accommodation.GetInventoryAPIType(PropId);
            int         result           = 0;
            List <long> accIds           = new List <long>();

            foreach (CLayer.BookingAccDetails t in bookingInfo)
            {
                accIds.Add(t.AccommodationId);
            }

            List <CLayer.Rates> accrates;

            CLayer.Role.Roles rle = BLayer.User.GetRole(userId);
            if (rle == CLayer.Role.Roles.CorporateUser || rle == CLayer.Role.Roles.Corporate)
            {
                accrates = BLayer.Rate.GetTotalRates(accIds, checkIn, checkOut, CLayer.Role.Roles.Corporate, userId, InventoryAPIType);
            }
            else
            {
                accrates = BLayer.Rate.GetTotalRates(accIds, checkIn, checkOut, CLayer.Role.Roles.Customer, userId, InventoryAPIType);
            }

            int cnt, i;

            cnt = bookingInfo.Count;
            CLayer.Booking bk = new CLayer.Booking();
            bk.BookingDate = DateTime.Today;
            bk.CheckIn     = checkIn;
            bk.CheckOut    = checkOut;
            bk.NoOfDays    = (checkOut - checkIn).Days;
            bk.Status      = (int)CLayer.ObjectStatus.BookingStatus.Offline;
            bk.BookingId   = bookingId;
            bk.ByUserId    = userId;
            bk.BookingId   = BLayer.Bookings.SaveInitialDataForOfflinBeforConfirm(bk);


            BLayer.Bookings.SetPaymentRefNo(bk.BookingId, rle, orderNo);
            bookingId = bk.BookingId;
            List <CLayer.BookingItem> items = new List <CLayer.BookingItem>();

            CLayer.BookingItem bitem;
            DateTime           lockIn = DateTime.Now;
            int minutes = 0;

            int.TryParse(BLayer.Settings.GetValue(CLayer.Settings.LOCKIN_TIME), out minutes);
            lockIn = lockIn.AddMinutes(minutes);


            //Delete All Booking Items Befor Modify to New Booking by booking id

            BLayer.BookingItem.DeleteAllItemsByBookingId(bookingId);
            BLayer.BookingItem.DeleteAllTaxItemsByBookingId(bookingId);

            for (i = 0; i < cnt; i++)
            {
                foreach (CLayer.Rates rt in accrates)
                {
                    if (bookingInfo[i].AccommodationId == rt.AccommodationId)
                    {
                        if (bookingInfo[i].AccCount <= rt.NoofAcc && bookingInfo[i].AccCount != 0)
                        {
                            bitem                    = new CLayer.BookingItem();
                            bitem.CheckIn            = checkIn;
                            bitem.CheckOut           = checkOut;
                            bitem.BookingId          = bookingId;
                            bitem.AccommodationId    = rt.AccommodationId;
                            bitem.ForUser            = userId;
                            bitem.NoOfAccommodations = bookingInfo[i].AccCount;
                            bitem.NoOfAdults         = bookingInfo[i].Adults;
                            bitem.NoOfChildren       = bookingInfo[i].Children;
                            bitem.NoOfGuests         = bookingInfo[i].Guest;

                            bitem.Cus_SupplierAmount   = bookingInfo[i].Cus_SupplierAmount;
                            bitem.Cus_TotalAmount      = bookingInfo[i].Cus_TotalAmount;
                            bitem.Cus_TaxAmount        = bookingInfo[i].Cus_TaxAmount;
                            bitem.Cus_GrandTotalAmount = bookingInfo[i].Cus_GrandTotalAmount;

                            bitem.LockInTime = lockIn;
                            bitem.Status     = (int)CLayer.ObjectStatus.StatusType.Active;
                            items.Add(bitem);
                            bitem.BookingItemId = BLayer.BookingItem.SaveIntialData(bitem);
                        }
                    }
                }
            }

            long propertyId         = BLayer.Accommodation.GetPropertyId(accrates[0].AccommodationId);
            List <CLayer.Tax> taxes = BLayer.Tax.GetAllForProperty(propertyId, checkIn, bk.BookingDate);
            List <CLayer.Tax> onTotalAmountTaxes = taxes.Where(m => m.OnTotalAmount == true).OrderBy(m => m.PriceUpto).ToList();
            List <CLayer.Tax> ordinaryTaxes      = taxes.Where(m => m.OnTotalAmount == false).OrderBy(m => m.PriceUpto).ToList();
            decimal           totalTax           = 0;
            decimal           guestRate          = 0;
            decimal           tt         = 0;
            StringBuilder     ratApplied = new StringBuilder();

            foreach (CLayer.BookingItem item in items)
            {
                foreach (CLayer.Rates rat in accrates)
                {
                    if (item.AccommodationId == rat.AccommodationId)
                    {
                        totalTax = 0;
                        ratApplied.Clear();
                        guestRate        = ((rat.GuestRate + rat.TotalGuestTax) * item.NoOfGuests);
                        item.TotalAmount = ((rat.Amount + rat.TotalRateTax) * item.NoOfAccommodations) + guestRate;
                        totalTax         = BLayer.Tax.GetTaxOnAmount(ordinaryTaxes, item.TotalAmount, item.BookingItemId);
                        totalTax         = totalTax + BLayer.Tax.GetTaxOnAmount(onTotalAmountTaxes, item.TotalAmount + totalTax, item.BookingItemId);
                        item.Amount      = Math.Round((rat.SupplierRate * item.NoOfAccommodations) + (rat.SupplierGuestRate * item.NoOfGuests));
                        if (rat.RateChanges != null && rat.RateChanges.Count > 0)
                        {
                            for (int ri = 0; ri < rat.RateChanges.Count; ri++)
                            {
                                if (ratApplied.Length > 0)
                                {
                                    ratApplied.Append(",");
                                }
                                ratApplied.Append(rat.RateChanges[ri].StartDate);
                                ratApplied.Append("#");
                                tt = (decimal)Math.Round(rat.RateChanges[ri].DayTotalCharge + (rat.RateChanges[ri].DayTotalGuestCharge * item.NoOfGuests));
                                ratApplied.Append(tt);
                            }
                            tt = (decimal)Math.Round(rat.RateChanges[0].DayTotalCharge + (rat.RateChanges[0].DayTotalGuestCharge * item.NoOfGuests));
                        }
                        else
                        {
                            tt = 0;
                        }
                        item.FirstDayCharge = tt;
                        item.TotalTax       = totalTax;
                        item.TotalRateTax   = Math.Round(rat.TotalRateTax * item.NoOfAccommodations);
                        item.TotalGuestTax  = Math.Round(rat.TotalGuestTax * item.NoOfGuests);
                        // include tax with amount
                        item.TotalAmount = Math.Round(item.TotalAmount);
                        item.GuestAmount = Math.Round(guestRate);

                        item.RatesApplied            = ratApplied.ToString();
                        item.CorporateDiscountAmount = rat.CorpDiscount;
                        item.CommissionSB            = rat.SBMarkup;
                        if (item.NoOfGuests > 0)
                        {
                            item.CommissionSB            += rat.SBGuestMarkup;
                            item.CorporateDiscountAmount += rat.CorpGuestDiscount;
                        }


                        BLayer.BookingItem.SaveAmounts(item);
                        BLayer.BookingItem.UpdateCustomBook(item.BookingItemId, 0);

                        //update custom amount
                        if (item.Cus_GrandTotalAmount > 0)
                        {
                            item.Amount                  = item.Cus_GrandTotalAmount;
                            item.TotalAmount             = item.Cus_GrandTotalAmount;
                            item.TotalTax                = item.Cus_TaxAmount;
                            item.TotalRateTax            = item.Cus_TaxAmount;
                            item.CommissionSB            = item.Cus_TotalAmount - item.Cus_SupplierAmount;
                            item.GuestAmount             = 0;
                            item.TotalGuestTax           = 0;
                            item.CorporateDiscountAmount = 0;
                            BLayer.BookingItem.SaveAmounts(item);
                            BLayer.BookingItem.UpdateCustomBook(item.BookingItemId, 1);
                        }



                        // save tax rate for each bookingitemid

                        long BItId             = item.BookingItemId;
                        long BookId            = item.BookingId;
                        long Pid               = BLayer.Accommodation.GetPropertyId(rat.AccommodationId);
                        List <CLayer.Tax> tax1 = BLayer.Tax.GetPropertyTaxById(Pid);

                        if (item.Cus_GrandTotalAmount > 0)
                        {
                        }
                        else
                        {
                            foreach (CLayer.Tax tx in tax1)
                            {
                                decimal TaxAmountBItem = Math.Round(((tx.Rate / tax) * ((rat.TotalRateTax * item.NoOfAccommodations) + (rat.TotalGuestTax * item.NoOfGuests))));
                                BLayer.BookingItem.SaveBookingtaxdata(BookId, BItId, tx.TaxTitleId, tx.Rate, TaxAmountBItem);
                            }
                            if (rat.AppliedOffers != null && rat.AppliedOffers.Count > 0)
                            {
                                foreach (CLayer.BookingItemOffer bo in rat.AppliedOffers)
                                {
                                    BLayer.BookingItem.AddOffer(item.BookingItemId, bo.OfferId, bo.OfferTitle);
                                }
                            }
                        }
                    }
                }
            }


            BLayer.Bookings.UpdateAmounts(bookingId);


            //add paypal commision outside india users
            long UserId = BLayer.Bookings.GetBookedByUserId(bookingId);

            CLayer.User dat = BLayer.User.GetCountrUser(UserId);
            string      ct  = dat.Country;

            if (ct != "India")
            {
                decimal paypalcomm         = Convert.ToDecimal(BLayer.Settings.GetValue(CLayer.Settings.PAYPAL_COMMISSION));
                decimal GrandTotalAmt      = Math.Round(BLayer.Bookings.GetTotal(bookingId));
                decimal TotalAmtIncPayComm = Math.Round(GrandTotalAmt + (paypalcomm * GrandTotalAmt / 100));
                BLayer.Bookings.SavePaypalComm((GrandTotalAmt * paypalcomm / 100), bookingId);
                BLayer.Bookings.UpdateTotalAmtIncPayComm(TotalAmtIncPayComm, bookingId);
            }



            //PartialPaymentbooking

            CLayer.Role.Roles UsertypeId        = BLayer.User.GetRole(userId);
            decimal           Partialamountperc = 0;

            if (UsertypeId == CLayer.Role.Roles.Customer)
            {
                Partialamountperc = Math.Round(BLayer.Property.GetPropertyB2CpartialamountPerc(propertyId));
            }
            if (UsertypeId == CLayer.Role.Roles.Administrator || UsertypeId == CLayer.Role.Roles.Corporate || UsertypeId == CLayer.Role.Roles.Affiliate || UsertypeId == CLayer.Role.Roles.Supplier || UsertypeId == CLayer.Role.Roles.CorporateUser)
            {
                Partialamountperc = Math.Round(BLayer.Property.GetPropertyB2BpartialamountPerc(propertyId));
            }

            decimal Partialamount   = Math.Round((Partialamountperc * Math.Round(BLayer.Bookings.GetTotal(bookingId))) / 100);
            decimal remainingamount = Math.Round(Math.Round(BLayer.Bookings.GetTotal(bookingId)) - Partialamount);

            BLayer.BookingItem.SavePartialAmount(bookingId, Partialamountperc, Partialamount, remainingamount);

            result = 1;

            return(result);
        }
Beispiel #21
0
        public ActionResult Index()
        {
            string userid = User.Identity.GetUserId();
            string email  = User.Identity.GetUserName();

            CLayer.Role.Roles role = (CLayer.Role.Roles)BLayer.User.GetRole(email);


            long id = 0;

            long.TryParse(userid, out id);//70 [email protected]
            Models.BookingHistoryModel search     = new Models.BookingHistoryModel();
            List <CLayer.Booking>      users      = BLayer.BookingHistory.GetHistoryForUser((int)CLayer.ObjectStatus.BookingStatus.Success, id, 90, 0, 25, 1);
            List <CLayer.Booking>      Creditbkgs = BLayer.BookingHistory.GetCreditBookForUser((int)CLayer.ObjectStatus.BookingStatus.Success, id, 0, 25);
            List <CLayer.Booking>      OtherBkgs  = BLayer.BookingHistory.GetOtherBookForUser((int)CLayer.ObjectStatus.BookingStatus.offlineconfirm, id, 0, 25);

            List <CLayer.OfflineBooking> Others = BLayer.OfflineBooking.GetAllForSearch_customer("", 1, 0, 10, 0, id, DateTime.Today.AddDays(DATERANGE), DateTime.Today);

            List <CLayer.Booking> ReadyForBookingList = new List <CLayer.Booking>();
            List <CLayer.Booking> RejectedBookingList = new List <CLayer.Booking>();

            //if (role == CLayer.Role.Roles.Corporate)
            //{
            ReadyForBookingList = BLayer.BookingHistory.GtbookingApprovedOrRejectedBookings((int)CLayer.ObjectStatus.BookingStatus.Approved, id, 90, 0, 25, 1);
            RejectedBookingList = BLayer.BookingHistory.GtbookingCancelledOrFailedOrRejectedBookings((int)CLayer.ObjectStatus.BookingStatus.Decline, id, 90, 0, 25, 1);

            //}
            //else if (role == CLayer.Role.Roles.CorporateUser)
            //{
            //    ReadyForBookingList = BLayer.BookingHistory.GtbookingApprovedOrRejectedBookings((int)CLayer.ObjectStatus.BookingStatus.Approved, id, 90, 0, 25, 1);
            //    RejectedBookingList = BLayer.BookingHistory.GtbookingApprovedOrRejectedBookings((int)CLayer.ObjectStatus.BookingStatus.Decline, id, 90, 0, 25, 1);

            //}



            search.Status                  = (int)CLayer.ObjectStatus.StatusType.Active;
            ViewBag.SearchValue            = 1;
            search.Day                     = 90;
            search.Type                    = 1;
            search.TotalRows               = 0;
            ViewBag.TotalRows              = 0;
            ViewBag.Limit                  = 10;
            ViewBag.currentPage            = 1;
            search.Bookinglist             = users;
            search.CreditBookinglist       = Creditbkgs;
            search.OtherBookinglist        = OtherBkgs;
            search.OtherofflineBookinglist = Others;
            search.ReadyForBookinglist     = ReadyForBookingList;
            search.RejectedBookinglist     = RejectedBookingList;
            if (users.Count > 0)
            {
                search.TotalRows  = users[0].TotalRows;
                ViewBag.TotalRows = users[0].TotalRows;
            }
            if (Others.Count > 0)
            {
                ViewBag.TotalRows = Others[0].TotalRows;
            }
            search.Limit       = 25;
            search.currentPage = 1;
            search.FromDate    = DateTime.Today.AddDays(DATERANGE);
            search.ToDate      = DateTime.Today;
            ViewBag.Filter     = search;

            return(View(search));
        }
Beispiel #22
0
        public async Task <bool> OfflineBookingConfirmGST(long OfflineBookId, long BookingDetailsId, string GuestEmail)
        {
            try
            {
                if (OfflineBookId < 1)
                {
                    return(false);
                }
                if (BookingDetailsId < 1)
                {
                    return(false);
                }
                CLayer.OfflineBooking Offlinedata = BLayer.OfflineBooking.GetAllDetailsById(OfflineBookId);

                CLayer.OfflineBooking OfflinePropertydata = BLayer.OfflineBooking.GetAllpropertyDetails(OfflineBookId);

                CLayer.OfflineBooking CustomerDetails = BLayer.OfflineBooking.GetAllCustomerDetails(OfflineBookId);

                if (CustomerDetails == null)
                {
                    return(false);
                }
                if (OfflinePropertydata == null)
                {
                    return(false);
                }

                CLayer.StayCategory      Staycategorydetails      = BLayer.StayCategory.Get(Convert.ToInt32(Offlinedata.StayCategoryid));
                CLayer.AccommodationType AccommodationTypedetails = BLayer.AccommodationType.Get(Convert.ToInt32(Offlinedata.Accommodationtypeid));

                CLayer.Role.Roles rle = BLayer.User.GetRole(Offlinedata.CustomerId);

                string        message = "";
                Common.Mailer ml      = new Common.Mailer();

                try
                {
                    #region Repeat portion

                    //List<CLayer.OfflineBooking> BListGST = BLayer.OfflineBooking.GetMultipleBookingDetailsGST(OfflineBookId);
                    //foreach (CLayer.OfflineBooking dt in BListGST)
                    //{

                    System.Net.Mail.MailMessage customerMsg = new System.Net.Mail.MailMessage();
                    //customerMsg.To.Add(CustomerDetails.CustomerEmail);
                    string BccEmailsforcususer = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                    if (BccEmailsforcususer.Trim() != "")
                    {
                        string[] emails = Common.Utils.SplitEmails(BccEmailsforcususer);
                        //BccEmailsforcususer.Split(',');
                        for (int i = 0; i < emails.Length; ++i)
                        {
                            customerMsg.CC.Add(emails[i]);
                        }
                    }


                    customerMsg.Subject    = "CHECK-IN REMINDER";
                    customerMsg.IsBodyHtml = true;

                    if (GuestEmail != null)
                    {
                        if (GuestEmail != null && GuestEmail != "")
                        {
                            string[] emails = Common.Utils.SplitEmails(GuestEmail);
                            for (int i = 0; i < emails.Length; ++i)
                            {
                                customerMsg.To.Add(emails[i]);
                            }
                        }
                    }

                    string link = System.Configuration.ConfigurationManager.AppSettings.Get("OfflineBookingConfirmationBeforeCheckin") + OfflineBookId.ToString() + "&BookingDetailsId=" + BookingDetailsId + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK);
                    message = await Common.Mailer.MessageFromHtml(link);

                    customerMsg.Body = message;



                    //Select Distinct Mail address in To mails

                    System.Net.Mail.MailAddress[] DistinctTo = customerMsg.To.Distinct().ToArray();
                    customerMsg.To.Clear();
                    for (int i = 0; i < DistinctTo.Length; ++i)
                    {
                        customerMsg.To.Add(DistinctTo[i]);
                    }

                    //Select Distinct Mail address in CC mails

                    System.Net.Mail.MailAddress[] DistinctCC = customerMsg.CC.Distinct().Except(DistinctTo).ToArray();
                    customerMsg.CC.Clear();
                    for (int i = 0; i < DistinctCC.Length; ++i)
                    {
                        customerMsg.CC.Add(DistinctCC[i]);
                    }



                    try
                    {
                        await ml.SendMailAsync(customerMsg, Common.Mailer.MailType.Reservation);
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }

                    //}
                    #endregion
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }

            return(true);
        }
Beispiel #23
0
        //**Added by rahul on 04/03/2020
        //*This is for getting rates for property Accommodation for API
        public List <CLayer.Rates> GetAccommodationRatesForAPI(string AccIds, DateTime checkIn, DateTime checkOut, int noOfDays, CLayer.Role.Roles rateType, CLayer.Role.Roles defaultType)
        {
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pAccs", DataPlug.DataType._Varchar, AccIds));
            param.Add(Connection.GetParameter("pCheckIn", DataPlug.DataType._Date, checkIn));
            param.Add(Connection.GetParameter("pCheckOut", DataPlug.DataType._Date, checkOut));
            param.Add(Connection.GetParameter("pRateType", DataPlug.DataType._Int, rateType));
            param.Add(Connection.GetParameter("pDefaultRateType", DataPlug.DataType._Int, (int)defaultType));
            param.Add(Connection.GetParameter("pBookingDayCount", DataPlug.DataType._Int, (int)noOfDays));
            DataTable dt = Connection.GetTable("accommodation_GetAvailabilityAndRateForAPI", param);

            List <CLayer.Rates> result = new List <CLayer.Rates>();

            CLayer.Rates rt;
            foreach (DataRow dr in dt.Rows)
            {
                rt = new CLayer.Rates();
                rt.AccommodationId      = Connection.ToLong(dr["AccommodationId"]);
                rt.Amount               = Connection.ToDecimal(dr["Amount"]);
                rt.GuestRate            = Connection.ToDecimal(dr["GuestRate"]);
                rt.StartDate            = Connection.ToDate(dr["startdate"]);
                rt.EndDate              = Connection.ToDate(dr["enddate"]);
                rt.RateType             = Connection.ToInteger(dr["AType"]);
                rt.NoofAcc              = Connection.ToInteger(dr["noofacc"]);
                rt.PurchaseRateAfterTax = Connection.ToDecimal(dr["DailyRate"]);
                result.Add(rt);
            }
            return(result);
        }
Beispiel #24
0
        public long CreateGuest(string email, string phone, CLayer.ObjectStatus.StatusType userStatus, CLayer.Role.Roles userRole, CLayer.Address.AddressTypes addrType)
        {
            //`(pEmail VARCHAR(200),pPhone VARCHAR(20),pStatus INT, pToken VARCHAR(100),pUType INT,pAType INT)
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pEmail", DataPlug.DataType._Varchar, email));
            param.Add(Connection.GetParameter("pPhone", DataPlug.DataType._Varchar, phone));
            param.Add(Connection.GetParameter("pStatus", DataPlug.DataType._Int, (int)userStatus));
            param.Add(Connection.GetParameter("pUType", DataPlug.DataType._Int, (int)userRole));
            param.Add(Connection.GetParameter("pToken", DataPlug.DataType._Varchar, Guid.NewGuid().ToString()));
            param.Add(Connection.GetParameter("pAType", DataPlug.DataType._Int, (int)addrType));

            object obj = Connection.ExecuteQueryScalar("user_CreateGuest", param);

            return(Connection.ToLong(obj));
        }