public string StatusEdit(int BookingId, int Status)
 {
     try
     {
         string userid = User.Identity.GetUserId();
         long   id     = 0;
         long.TryParse(userid, out id);
         if (ModelState.IsValid)
         {
             CLayer.Booking dataStatus = new CLayer.Booking()
             {
                 BookingId = BookingId,
                 ByUserId  = id,
                 Status    = Status
             };
             BLayer.Transaction.BookingStatusChange(dataStatus);
             ViewBag.Saved = true;
         }
         else
         {
             ViewBag.Saved = false;
         }
         return(BookingId.ToString());
         // return RedirectToAction("Index");
     }
     catch (Exception ex)
     {
         Common.LogHandler.HandleError(ex);
         return("0");
     }
 }
        public ActionResult Index(long?BookingUserId)
        {
            Models.SaveBookingUserModel data = null;
            try
            {
                data = new Models.SaveBookingUserModel();
                long userId = 0;
                long.TryParse(User.Identity.GetUserId(), out userId);
                if (BookingUserId > 0)
                {
                    CLayer.Booking Getdata1 = BLayer.Bookings.GetBookedForBookingUserId(BookingUserId.Value);
                    if (Getdata1 != null)
                    {
                        data = new Models.SaveBookingUserModel()
                        {
                            FirstName = Getdata1.FirstName,
                            LastName  = Getdata1.LastName,
                            AddressId = Getdata1.AddressId,
                            Address   = Getdata1.Address,
                            CountryId = Getdata1.Country,
                            State     = Getdata1.State,
                            //CityId = Getdata1.CityId,
                            //City = Getdata1.City,
                            Phone   = Getdata1.Phone,
                            Email   = Getdata1.Email,
                            ZipCode = Getdata1.ZipCode,
                            Mobile  = Getdata1.Mobile
                        };


                        if (Getdata1.City != null && Getdata1.City != "")
                        {
                            data.City = Getdata1.City;
                        }
                        else
                        {
                            if (Getdata1.CityId > 0)
                            {
                                data.City = BLayer.City.Get(Getdata1.CityId).Name;
                            }
                        }

                        //if (data.State > 0)
                        //{
                        //    List<CLayer.City> cities = null;
                        //    cities = BLayer.City.GetOnState(data.State);
                        //    cities.Add(new CLayer.City() { CityId = -1, Name = "Other" });
                        //    data.CityList = new SelectList(cities, "CityId", "Name");
                        //}

                        data.LoadPlaces();
                    }
                }
            }catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(View(data));
        }
Esempio n. 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);
 }
        public async Task <bool> ResendemailS(long bookingId)
        {
            try
            {
                if (bookingId < 1)
                {
                    return(false);
                }
                CLayer.Booking details  = BLayer.Bookings.GetDetailsSMS(bookingId);
                CLayer.User    supplier = BLayer.Bookings.GetSupplierDetails(bookingId);
                try
                {
                    string        message = "";
                    Common.Mailer ml      = new Common.Mailer();
                    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);
            }
            return(true);
        }
Esempio n. 5
0
        public Models.BookingModel LoadVal(long bookingId)
        {
            Models.BookingModel data = new Models.BookingModel();
            //    CLayer.Address wh = BLayer.Bookings.GetBookedByUser(bookingId);
            //List<CLayer.Address> adr = BLayer.Bookings.GetOfflineBookedForUser(bookingId);//This is for offlineboookings
            List <CLayer.Address> adr = BLayer.Bookings.GetBookedForUser(bookingId);//This is for API booking

            if (adr.Count == 0)
            {
                adr.Add(new CLayer.Address());
            }
            data.OrderedBy = adr[0];
            // data.Items = BLayer.BookingItem.GetAllDetails(bookingId);
            //long propertyId = BLayer.BookingExternalInventory.GetPropertyIdByOfflineBookingId(bookingId);//*this is for getting property id of offline_booking
            long propertyId       = BLayer.BookingExternalInventory.GetPropertyIdByBookingId(bookingId);//this is for getting property id of booking
            int  InventoryAPIType = BLayer.Property.GetInventoryAPITypeId(BLayer.Bookings.GetPropertyId(bookingId));

            ViewBag.InventoryAPIType = InventoryAPIType;
            if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus)
            {
                data.Items = BLayer.BookingItem.GetAllDetails(bookingId, true);
            }
            else
            {
                //data.Items = BLayer.BookingItem.GetAllOfflineDetails(bookingId);
                data.Items = BLayer.BookingItem.GetAllDetails(bookingId);//*This is getting details for booking or API Booking
            }
            //CLayer.Booking bdata = BLayer.Bookings.GetOfflineBookingDetails(bookingId);//*This is for getting orderno and other details of Offline bookings
            CLayer.Booking bdata = BLayer.Bookings.GetDetails(bookingId);//*This is for getting orderno and other details of online bookings or API booking
            data.BookingDetails.OrderNo     = bdata.OrderNo;
            data.BookingDetails.BookingDate = bdata.BookingDate;
            if (InventoryAPIType == (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus)
            {
                data.Supplier = BLayer.Bookings.GetSupplierDetailsAmadeus(bookingId);
            }
            else
            {
                // data.Supplier = BLayer.Bookings.GetSupplierDetailsofOfflineBooking(bookingId);//This is for getting supplier detials of Offline Booking
                data.Supplier = BLayer.Bookings.GetSupplierDetails(bookingId);//This is for getting supplier detials of Online Booking or API booking
            }

            data.BookingId = bookingId;

            //data.LoggedInUserName = BLayer.Bookings.GetCurrentApproverNameForMailOfOfflineBooking(bookingId);//*This is for getting userid of OfflineBooking
            data.LoggedInUserName = BLayer.Bookings.GetCurrentApproverNameForMail(bookingId);//*this is for getting user id of Online booking or APi

            ViewBag.propertyId = propertyId;

            //Models.SimpleBookingModel Amedusdata = (Models.SimpleBookingModel)TempData["AmedusData"];
            //List<CLayer.Tax> objAmadeusTaxRates = (List<CLayer.Tax>)Session["Amedustaxrates"];
            //ViewBag.Amadeustaxrates = Session["Amedustaxrates"];
            return(data);
        }
        public ActionResult SaveDetails(Models.SaveBookingUserModel data)
        {
            try
            {
                CLayer.Address adr = new CLayer.Address();
                adr.AddressId   = data.AddressId;
                adr.AddressType = (int)CLayer.Address.AddressTypes.Normal;
                adr.AddressText = data.Address;
                if (data.City != null && data.City != "")
                {
                    adr.City = data.City;
                }
                else
                {
                    if (data.CityId > 0)
                    {
                        adr.City = BLayer.City.Get(data.CityId).Name;
                    }
                }
                adr.State     = data.State;
                adr.CountryId = data.CountryId;
                adr.Phone     = data.Phone;
                adr.Mobile    = data.Mobile;
                // adr.UserId = 1;
                adr.CityId = data.CityId;
                //  adr.City = data.City;
                adr.ZipCode = data.ZipCode;

                adr.UserId = 0;
                long id = BLayer.Address.Save(adr);

                CLayer.Booking usr = new CLayer.Booking();
                usr.ForBookingUserId = data.BookingUserId;
                usr.FirstName        = data.FirstName;
                usr.LastName         = data.LastName;
                usr.Email            = data.Email;
                usr.Mobile           = data.Mobile;
                usr.AddressId        = id;
                long userId = GetUserId();
                usr.ByUserId = userId;


                long ForBookingUserId = BLayer.Bookings.SaveBookingFor(usr); //add new for booking user
                long bookingId        = BLayer.Bookings.GetCartId(userId);   //getbookingId
                BLayer.Bookings.UpdateBooking(ForBookingUserId, bookingId);  //update bookingitems ForuserId
                return(RedirectToAction("Index", "Booking"));
            } catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/ErrorPage"));
            }
        }
Esempio n. 7
0
        public ActionResult BookingModify(long BookingId)
        {
            Models.OfflinePropertyBookingModel model = new Models.OfflinePropertyBookingModel();
            long PropertyId = BLayer.Bookings.GetPropertyId(BookingId);

            CLayer.Property Pdata   = BLayer.Property.Get(PropertyId);
            CLayer.B2B      supdata = BLayer.B2B.Get(Pdata.OwnerId);

            CLayer.Booking            offedit = BLayer.Bookings.GetBookDetailsByBookingId(BookingId);
            List <CLayer.BookingItem> Items   = BLayer.BookingItem.GetAllDetailsforoffline(BookingId);

            model.PropertyId        = PropertyId;
            model.PropertyName      = Pdata.Title;
            model.PropertyAddress   = Pdata.Address;
            model.PropertyCity      = Pdata.CityId;
            model.PropertyCityname  = Pdata.City;
            model.PropertyState     = Pdata.State;
            model.PropertyCountry   = Pdata.Country;
            model.PropertyContactNo = Pdata.Phone;
            model.PropertyEmail     = Pdata.Email;
            model.SupplierName      = supdata.Name;


            model.Accommodationid     = offedit.AccommodationId;
            model.Accommodationtypeid = offedit.AccommodationTypeId;
            model.AccommodatoinType   = Convert.ToInt16(offedit.AccommodationType);
            string ccc = BLayer.Accommodation.GetAccommodationTitle(offedit.AccommodationId);

            model.AccommodationTypeName = ccc;
            model.StayCategoryid        = offedit.StayCategoryId;
            model.CheckIn  = offedit.CheckIn.ToString("dd/MM/yyyy");
            model.CheckOut = offedit.CheckOut.ToString("dd/MM/yyyy");
            //model.NoOfNight = offedit.NoOfNight;
            //model.NoOfRooms = offedit.NoOfRooms;
            model.NoOfPaxAdult   = offedit.NoOfAdults;
            model.NoOfPaxChild   = offedit.NoOfChildren;
            model.Type           = 2;
            model.bookingitmList = Items;
            model.Count          = Items.Count;

            model.BookingId  = BookingId;
            model.CustomerId = BLayer.Bookings.GetBookedByUserId(BookingId);
            return(View("_BookingModify", model));
        }
Esempio n. 8
0
        public Models.BookingModel LoadVal(long bookingId)
        {
            Models.BookingModel data = new Models.BookingModel();
            //    CLayer.Address wh = BLayer.Bookings.GetBookedByUser(bookingId);
            List <CLayer.Address> adr = BLayer.Bookings.GetBookedForUser(bookingId);

            if (adr.Count == 0)
            {
                adr.Add(new CLayer.Address());
            }
            data.OrderedBy = adr[0];
            data.Items     = BLayer.BookingItem.GetAllDetails(bookingId);
            CLayer.Booking bdata = BLayer.Bookings.GetDetails(bookingId);
            data.BookingDetails.OrderNo     = bdata.OrderNo;
            data.BookingDetails.BookingDate = bdata.BookingDate;
            data.Supplier  = BLayer.Bookings.GetSupplierDetails(bookingId);
            data.BookingId = bookingId;
            return(data);
        }
Esempio n. 9
0
        //   public string OrderNo { get; set; }
        public BookingModel()
        {
            Items          = new List <CLayer.BookingItem>();
            OrderedBy      = new CLayer.Address();
            Forbookings    = new BookingForUserModel();
            BookingDetails = new CLayer.Booking();
            offeritems     = new CLayer.Offers();
            Supplier       = new CLayer.User();
            ForPrint       = false;
            ForPdf         = false;

            List <CLayer.B2BUser> CorporateList = BLayer.B2BUser.GetCorporateName();

            CorporateName = new SelectList(CorporateList, "B2BId", "FirstName");
            //For getting Corporate User's Name under Corporate
            List <CLayer.B2BUser> CorporateUserList = BLayer.B2BUser.GetOnCorporateUserList((int)CorporateList[0].B2BId);

            CorporateUserName = new SelectList(CorporateUserList, "UserId", "FirstName");
        }
Esempio n. 10
0
        public async Task <string> Email()
        {
            WebClient wc = new WebClient();

            try
            {
                Models.BookingModel   data    = new Models.BookingModel();
                List <CLayer.Booking> dt      = BLayer.Bookings.GetPartialBookingDetails();
                string         url            = ConfigurationManager.AppSettings.Get(URL_PARTIALPAYMENT);
                long           BookId         = 0;
                CLayer.Booking PaymentDetails = null;
                MailMessage    mm             = new MailMessage();
                mm.Bcc.Add(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
                mm.From = new MailAddress(ConfigurationManager.AppSettings.Get("CustomerCareMail"));
                Common.Mailer mlr = new Common.Mailer();
                mm.IsBodyHtml = true;
                mm.Subject    = "Reminder: Payment pending";
                foreach (CLayer.Booking book in dt)
                {
                    PaymentDetails = book;
                    BookId         = book.BookingId;
                    string result = wc.DownloadString(url + BookId);
                    mm.To.Clear();
                    mm.To.Add(book.Email);
                    //mm.ReplyToList.Add("*****@*****.**");
                    mm.Body = result;
                    await mlr.SendMailAsyncWithoutFields(mm);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return("false");
            }
            return("true");
            //return View();
        }
Esempio n. 11
0
 //***Added by rahul on 28/02/20 for Saving Initial data for offline bookings
 public static long SaveOfflineBookingInitialData(CLayer.Booking data)
 {
     DataLayer.Booking book = new DataLayer.Booking();
     return(book.SaveOfflinebookingInitialData(data));
 }
Esempio n. 12
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);
        }
        //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);
        }
Esempio n. 14
0
        public static CLayer.CancellationData GetModifyInfo(long bookingId, long offlinebookings, DateTime newCheckIn, DateTime newCheckOut, long userId)
        {
            CLayer.CancellationData result      = new CLayer.CancellationData();
            CLayer.Booking          bookDetails = BLayer.Bookings.GetDetails(bookingId);
            DateTime checkIn  = bookDetails.CheckIn;
            DateTime checkout = bookDetails.CheckOut;
            int      addDays  = 0;

            DateTime p1cn, p1co, p2cn, p2co, crdate;

            crdate = p1co = p2co = p1cn = p2cn = DateTime.Today;
            int cancelDays = 0;

            //days to cancel - canceldays
            if (newCheckIn > checkIn)
            {
                cancelDays = (newCheckIn - checkIn).Days;
            }

            if (newCheckOut < checkout)
            {
                cancelDays = cancelDays + (checkout - newCheckOut).Days;
            }

            //additional days
            if (newCheckIn < checkIn)
            {
                addDays = (checkIn - newCheckIn).Days;
            }
            if (newCheckOut > checkout)
            {
                addDays = addDays + (newCheckOut - checkout).Days;
            }
            //find days to book
            if (newCheckIn < checkIn)
            {
                p1cn = newCheckIn;
                p1co = checkIn;
            }
            if (newCheckOut > checkout)
            {
                p2cn = checkout;
                p2co = newCheckOut;
            }
            result.AdditionalDays = addDays;
            result.CancelledDays  = cancelDays;
            //find cancellation charge and refund - and process cancellation
            decimal totalCharge = 0;
            long    propertyId  = BLayer.Bookings.GetPropertyId(bookingId);

            if (cancelDays > 0)
            {
                decimal         firstDay    = 0;
                CLayer.Property cancCharges = BLayer.Property.GetCancellationCharges(propertyId);
                firstDay = BLayer.Bookings.GetFirstDayCharge(bookingId);
                if (cancCharges.IsChargeAppliesToRefund)
                {
                    totalCharge = BLayer.Bookings.GetTotalCancellationCharge(cancCharges, (firstDay * cancelDays), firstDay, checkIn);
                }
                result.Refundable = Math.Round((firstDay * cancelDays) - totalCharge);     // refundable amount
                List <CLayer.Transaction> refundable = BLayer.Transaction.GetAllRefundable(bookingId);
                if (refundable.Count > 0)
                {
                    result.ServiceCharge = BLayer.Transaction.GetTotalCancellationServiceCharge(bookingId, ref refundable, result.Refundable);
                }
                result.Refundable = Math.Round(result.Refundable - (decimal)result.ServiceCharge);
                if (result.Refundable < 0)
                {
                    result.Refundable = 0;
                }
            }
            result.TotalCancellationCharge = totalCharge;

            int adults, kids, guests;
            List <CLayer.BookingItem> oneitem = BLayer.BookingItem.GetAllDetails(bookingId);

            adults = oneitem[0].NoOfAdults;
            kids   = oneitem[0].NoOfChildren;
            guests = oneitem[0].NoOfGuests;
            //find new booking charge and availablity
            BLayer.Bookings.ClearCart(userId);
            bookingId = BLayer.Bookings.GetCartIdAfterCleaning(userId);

            List <CLayer.BookingAccDetails> binfo = new List <CLayer.BookingAccDetails>();

            if (p1cn != crdate)
            {
                foreach (CLayer.BookingItem bi in oneitem)
                {
                    binfo.Add(new CLayer.BookingAccDetails()
                    {
                        AccommodationId = bi.AccommodationId,
                        AccCount        = bi.NoOfAccommodations,
                        Adults          = adults,
                        Children        = kids,
                        Guest           = guests
                    });
                }

                BLayer.Rate.BookAccommodations(binfo, p1cn, p1co, userId, bookingId, offlinebookings, bookDetails.OrderNo);
            }
            if (bookingId == 0)
            {
                bookingId = BLayer.Bookings.GetCartId(userId);
            }
            if (p2cn != crdate)
            {
                binfo.Clear();
                foreach (CLayer.BookingItem bi in oneitem)
                {
                    binfo.Add(new CLayer.BookingAccDetails()
                    {
                        AccommodationId = bi.AccommodationId,
                        AccCount        = bi.NoOfAccommodations,
                        Adults          = adults,
                        Children        = kids,
                        Guest           = guests
                    });
                }

                BLayer.Rate.BookAccommodations(binfo, p2cn, p2co, userId, bookingId, offlinebookings, bookDetails.OrderNo);
            }

            if (bookingId == 0)
            {
                bookingId = BLayer.Bookings.GetCartId(userId);
            }
            BLayer.Bookings.UpdateAmounts(bookingId);
            if (bookingId > 0)
            {
                result.NewBookingRate = BLayer.Bookings.GetTotal(bookingId);
            }
            BLayer.Bookings.ClearCart(userId);
            return(result);
        }
Esempio n. 15
0
        public static CLayer.CancellationData ModifyBooking(long bookingId, long offlineBookingId, DateTime newCheckIn, DateTime newCheckOut, long userId)
        {
            CLayer.CancellationData result      = new CLayer.CancellationData();
            CLayer.Booking          bookDetails = BLayer.Bookings.GetDetails(bookingId);
            DateTime checkIn  = bookDetails.CheckIn;
            DateTime checkout = bookDetails.CheckOut;

            result.NewBookingExist = false;
            DateTime p1cn, p1co, p2cn, p2co, crdate;

            crdate = p1co = p2co = p1cn = p2cn = DateTime.Today;
            //days to cancel - canceldays
            int      cancelDays = 0;
            DateTime cancCheckIn, cancCheckOut;

            cancCheckIn  = checkIn;
            cancCheckOut = checkout;


            if (newCheckIn > checkIn)
            {
                cancelDays  = (newCheckIn - checkIn).Days;
                cancCheckIn = newCheckIn;
            }
            if (newCheckOut < checkout)
            {
                cancelDays   = cancelDays + (checkout - newCheckOut).Days;
                cancCheckOut = newCheckOut;
            }

            //find days to book
            if (newCheckIn < checkIn)
            {
                p1cn = newCheckIn;
                p1co = checkIn;
            }
            if (newCheckOut > checkout)
            {
                p2cn = checkout;
                p2co = newCheckOut;
            }

            //clean booking cart
            decimal totalCharge = 0;
            long    propertyId  = BLayer.Bookings.GetPropertyId(bookingId);

            if (cancelDays > 0)
            {
                //calculate the refunds
                decimal         firstDay      = 0;
                decimal         remainingAmnt = 0;
                CLayer.Property cancCharges   = BLayer.Property.GetCancellationCharges(propertyId);

                firstDay = BLayer.Bookings.GetFirstDayCharge(bookingId);
                List <CLayer.BookingItem> items = BLayer.BookingItem.GetAllDetails(bookingId);
                decimal fdi, tci;
                totalCharge = 0;

                foreach (CLayer.BookingItem bi in items)
                {
                    fdi = bi.FirstDayCharge;
                    if (cancCharges.IsChargeAppliesToRefund)
                    {
                        tci = Math.Round(BLayer.Bookings.GetTotalCancellationCharge(cancCharges, (fdi * cancelDays), firstDay, checkIn));
                    }
                    else
                    {
                        tci = 0;
                    }
                    totalCharge   = Math.Round(totalCharge + tci);
                    remainingAmnt = Math.Round(fdi * cancelDays - tci);
                    // remainingAmnt = remainingAmnt - tci;
                    bi.TotalAmount = Math.Round(bi.TotalAmount - remainingAmnt);
                    if (bi.TotalAmount < 0)
                    {
                        bi.TotalAmount = 0;
                    }
                    BLayer.BookingItem.SetCancAmount(bi.BookingItemId, tci, bi.TotalAmount);
                }
                //totalCharge = BLayer.Bookings.GetTotalCancellationCharge(cancCharges, (firstDay * cancelDays), firstDay, checkIn); //bookDetails.Amount

                List <CLayer.Transaction> refundable = BLayer.Transaction.GetAllRefundable(bookingId);
                if (refundable.Count > 0)
                {
                    result.ServiceCharge = BLayer.Transaction.GetTotalCancellationServiceCharge(bookingId, ref refundable);
                }
                remainingAmnt = Math.Round(firstDay * cancelDays);
                if (remainingAmnt > 0)
                {
                    remainingAmnt = remainingAmnt - totalCharge;
                    if (remainingAmnt > 0)
                    {
                        BLayer.Transaction.RefundAmount(bookingId, remainingAmnt, totalCharge);
                    }
                }
                BLayer.Bookings.UpdateTotals(bookingId);
                BLayer.BookingItem.UpdateCheckInAndOut(bookingId, cancCheckIn, cancCheckOut);

                //CANCEL EXTERNAL BOOKING REQUEST

                //set new external  booking request

                BLayer.Bookings.SetUpdatedDate(bookingId);
            }
            result.TotalCancellationCharge = totalCharge;

            int adults, kids, guests;
            List <CLayer.BookingItem> oneitem = BLayer.BookingItem.GetAllDetails(bookingId);

            adults = oneitem[0].NoOfAdults;
            kids   = oneitem[0].NoOfChildren;
            guests = oneitem[0].NoOfGuests;

            BLayer.Bookings.ClearCart(userId);
            long oldBookingId = bookingId;

            bookingId = BLayer.Bookings.GetCartIdAfterCleaning(userId);
            bookingId = BLayer.Bookings.GetOfflinebookingCartIdAfterCleaning(userId);


            List <CLayer.BookingAccDetails> binfo = new List <CLayer.BookingAccDetails>();

            if (p1cn != crdate)
            {
                result.NewBookingExist = true;
                foreach (CLayer.BookingItem bi in oneitem)
                {
                    binfo.Add(new CLayer.BookingAccDetails()
                    {
                        AccommodationId = bi.AccommodationId,
                        AccCount        = bi.NoOfAccommodations,
                        Adults          = adults,
                        Children        = kids,
                        Guest           = guests
                    });
                }

                BLayer.Rate.BookAccommodations(binfo, p1cn, p1co, userId, bookingId, offlineBookingId, bookDetails.OrderNo);
            }
            if (bookingId == 0)
            {
                bookingId = BLayer.Bookings.GetCartId(userId);
            }
            if (p2cn != crdate)
            {
                result.NewBookingExist = true;
                binfo.Clear();
                foreach (CLayer.BookingItem bi in oneitem)
                {
                    binfo.Add(new CLayer.BookingAccDetails()
                    {
                        AccommodationId = bi.AccommodationId,
                        AccCount        = bi.NoOfAccommodations,
                        Adults          = adults,
                        Children        = kids,
                        Guest           = guests
                    });
                }

                BLayer.Rate.BookAccommodations(binfo, p2cn, p2co, userId, bookingId, offlineBookingId, bookDetails.OrderNo);
            }

            if (bookingId == 0)
            {
                bookingId = BLayer.Bookings.GetCartId(userId);
            }

            BLayer.Bookings.CopyGuestDetails(oldBookingId, bookingId);

            BLayer.Bookings.UpdateAmounts(bookingId);
            if (bookingId > 0)
            {
                result.NewBookingRate = BLayer.Bookings.GetTotal(bookingId);
            }
            return(result);
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
        //**

        public static long SaveInitialDataForOfflinBeforConfirm(CLayer.Booking data)
        {
            DataLayer.Booking book = new DataLayer.Booking();
            return(book.SaveInitialDataForOfflinBeforConfirm(data));
        }
Esempio n. 18
0
 public static int BookingStatusChange(CLayer.Booking t)
 {
     DataLayer.Transaction save = new DataLayer.Transaction();
     return(save.StatusChange(t));
 }
Esempio n. 19
0
        //public static void CancelAccommodation(long bookingItemId)
        //{
        //    CLayer.BookingItem detail = BLayer.BookingItem.GetDetails(bookingItemId);
        //    List<CLayer.Transaction> refundable = BLayer.Transaction.GetAllRefundable(detail.BookingId);
        //    double serviceCharge = 0; // BLayer.Transaction.GetTotalCancellationServiceCharge(detail.BookingId, ref refundable, detail.Amount);
        //    decimal cancellationCharge = 0;
        //    decimal firstDayCharge = BLayer.BookingItem.GetFirstDayCharge(bookingItemId);
        //    CLayer.Property prp = BLayer.Property.GetCancellationCharges(BLayer.Bookings.GetPropertyId(detail.BookingId));
        //    if (detail.CheckIn.AddHours(-1 * (double)prp.CancellationPeriod) <= DateTime.Now)
        //    {
        //        cancellationCharge = BLayer.Bookings.GetTotalCancellationCharge(prp, detail.Amount, firstDayCharge, detail.CheckIn); ;
        //    }
        //    //found refund amount by reducing cancellation charge, service charge will be deducted once the transaction is done
        //    decimal RefundAmount = detail.TotalAmount - cancellationCharge;
        //    bool CanCancel = (RefundAmount > CLayer.Settings.TRANSACTION_MIN_AMOUNT);

        //    BLayer.BookingItem.SetStatus(bookingItemId, CLayer.ObjectStatus.StatusType.Disabled);

        //    if (CanCancel)
        //    {
        //        //mark as trying
        //        double amt = 0;
        //        decimal tryRefund = 0;
        //        foreach (CLayer.Transaction tran in refundable)
        //        {
        //            //(pPaymentId VARCHAR(12),pTryAmount DECIMAL(14,2), pTryTime DATETIME,pTotalAmount DECIMAL(14,2),pStatus INT)
        //            serviceCharge = GetServiceCharge((CLayer.ObjectStatus.PaymentMethod)tran.PaymentType);
        //            if (serviceCharge > 0)
        //            {
        //                serviceCharge = Math.Round((double)RefundAmount * serviceCharge / 100 * 2);
        //                RefundAmount = RefundAmount - (decimal)serviceCharge;
        //            }
        //            if (RefundAmount <= 0) break;
        //            amt = tran.TotalAmount;
        //            if (amt >= (double)RefundAmount)
        //            {
        //                amt = amt - (double)RefundAmount;
        //                tryRefund = RefundAmount;
        //                RefundAmount = 0;
        //            }
        //            else
        //            {
        //                RefundAmount = RefundAmount - (decimal)amt;
        //                tryRefund = (decimal)amt;
        //                amt = 0;
        //            }

        //            tran.TryAmount = tryRefund;
        //            tran.ServiceCharge = tran.ServiceCharge + serviceCharge;
        //            tran.TryTime = DateTime.Today;
        //            tran.TotalAmount = amt;
        //            tran.Status = CLayer.ObjectStatus.TransactionStatus.TryingForRefund;
        //            BLayer.Transaction.UpdateAmountAndStatus(tran);
        //            // if (RefundAmount <= 0) break;
        //        }

        //        foreach (CLayer.Transaction tran in refundable)
        //        {
        //            try
        //            {
        //                if (tran.Status != CLayer.ObjectStatus.TransactionStatus.TryingForRefund) continue;
        //                if (SendRefund(tran))
        //                {
        //                    if (tran.TotalAmount > 0)
        //                        tran.Status = CLayer.ObjectStatus.TransactionStatus.PartialRefund;
        //                    else
        //                        tran.Status = CLayer.ObjectStatus.TransactionStatus.Refunded;
        //                    tran.TryAmount = 0;
        //                    BLayer.Transaction.UpdateAmountAndStatus(tran);
        //                }

        //            }
        //            catch
        //            { }
        //        }
        //        //BLayer.Bookings.UpdateCharges(bookingId, cancellationCharge, (decimal)totalServiceCharge);
        //        //BLayer.Bookings.SetRefund(bookingId, totalRefund - (decimal)totalServiceCharge);
        //    }
        //}

        public static void CancelAllTransactions(long bookingId)
        {
            CLayer.ObjectStatus.BookingStatus BStatus = BLayer.Bookings.GetStatus(bookingId);
            long PayOption = BLayer.Bookings.GetPaymentoption(bookingId);

            CLayer.Booking            detail     = BLayer.Bookings.GetDetails(bookingId);
            List <CLayer.Transaction> refundable = BLayer.Transaction.GetAllRefundable(bookingId);
            double  serviceCharge      = 0;// BLayer.Transaction.GetTotalCancellationServiceCharge(bookingId, ref refundable);
            decimal cancellationCharge = 0;


            double totalServiceCharge = 0;

            decimal firstDayCharge = BLayer.Bookings.GetFirstDayCharge(bookingId);

            CLayer.Property prp      = BLayer.Property.GetCancellationCharges(BLayer.Bookings.GetPropertyId(bookingId));
            int             noOfDays = (detail.CheckOut - detail.CheckIn).Days;

            cancellationCharge = BLayer.Bookings.GetTotalCancellationCharge(prp, detail.TotalAmount, noOfDays * firstDayCharge, detail.CheckIn);

            if (BStatus == CLayer.ObjectStatus.BookingStatus.BookingRequest)
            {
                cancellationCharge = 0;
            }

            decimal RefundAmountFCancel = Math.Round(detail.TotalAmount - cancellationCharge);

            if (PayOption == (int)CLayer.ObjectStatus.PaymentOption.FullPayment)
            {
                RefundAmountFCancel = Math.Round(detail.TotalAmount - cancellationCharge);
            }
            else if (PayOption == (int)CLayer.ObjectStatus.PaymentOption.PartialPayment)
            {
                CLayer.ObjectStatus.PartialPaymentStatus PartialPayStatus = BLayer.Bookings.GetPartialPaymentStatus(bookingId);
                CLayer.Booking PartBookDt = BLayer.Bookings.GetPartialBookDetailsbyBookId(bookingId);

                if (PartialPayStatus == CLayer.ObjectStatus.PartialPaymentStatus.InitialPaymentSuccess || PartialPayStatus == CLayer.ObjectStatus.PartialPaymentStatus.SecondPaymentFailed || PartialPayStatus == CLayer.ObjectStatus.PartialPaymentStatus.Secondpaycheckout)
                {
                    RefundAmountFCancel = Math.Round(PartBookDt.PaymentFirstinstallment - cancellationCharge);
                }
                else if (PartialPayStatus == CLayer.ObjectStatus.PartialPaymentStatus.SecondPaymentSuccess)
                {
                    RefundAmountFCancel = Math.Round(detail.TotalAmount - cancellationCharge);
                }
            }


            bool CanCancel = (RefundAmountFCancel > CLayer.Settings.TRANSACTION_MIN_AMOUNT);


            if (BStatus == CLayer.ObjectStatus.BookingStatus.BookingRequest)
            {
                BLayer.Bookings.SetStatus((int)CLayer.ObjectStatus.BookingStatus.Decline, bookingId);
            }
            else
            {
                BLayer.Bookings.SetStatus((int)CLayer.ObjectStatus.BookingStatus.Cancelled, bookingId);
            }


            BLayer.Bookings.SetPartialPaymentStatus((int)CLayer.ObjectStatus.PartialPaymentStatus.BookingCancel, bookingId);
            BLayer.Bookings.SetUpdatedDate(bookingId);

            decimal totalRefund = RefundAmountFCancel;
            long    Gatewaytype = BLayer.Bookings.Getgatewaytype(bookingId);



            if (CanCancel)
            {
                //mark as trying
                double  amt       = 0;
                decimal tryRefund = 0;
                int     countlist = 0;
                foreach (CLayer.Transaction tran in refundable)
                {
                    decimal RefundAmount = RefundAmountFCancel;

                    if (PayOption == (int)CLayer.ObjectStatus.PaymentOption.FullPayment)
                    {
                        RefundAmount = RefundAmountFCancel;
                    }
                    else if (PayOption == (int)CLayer.ObjectStatus.PaymentOption.PartialPayment)
                    {
                        CLayer.Booking PartBookDt = BLayer.Bookings.GetPartialBookDetailsbyBookId(bookingId);
                        if (countlist == 0)
                        {
                            RefundAmount = Math.Round(PartBookDt.PaymentFirstinstallment - cancellationCharge);
                        }
                        else if (countlist == 1)
                        {
                            RefundAmount = Math.Round(PartBookDt.PaymentSecondinstallment - cancellationCharge);
                        }
                    }
                    else
                    {
                        RefundAmount = RefundAmountFCancel;
                    }



                    serviceCharge = GetServiceCharge((CLayer.ObjectStatus.PaymentMethod)tran.PaymentType);
                    if (serviceCharge > 0)
                    {
                        serviceCharge = Math.Round((double)RefundAmount * serviceCharge / 100 * 2);
                        if (BStatus == CLayer.ObjectStatus.BookingStatus.Decline)
                        {
                            serviceCharge = 0;
                        }
                        RefundAmount = RefundAmount - (decimal)serviceCharge;
                    }
                    if (RefundAmount <= 0)
                    {
                        break;
                    }
                    amt = tran.TotalAmount;



                    if (Gatewaytype == (int)CLayer.ObjectStatus.Gateway.EBS)
                    {
                        if (amt >= (double)RefundAmount)
                        {
                            amt          = amt - (double)RefundAmount;
                            tryRefund    = RefundAmount;
                            RefundAmount = 0;
                        }
                        else
                        {
                            RefundAmount = RefundAmount - (decimal)amt;
                            tryRefund    = (decimal)amt;
                            amt          = 0;
                        }
                    }
                    else if (Gatewaytype == (int)CLayer.ObjectStatus.Gateway.PayPal)
                    {
                        CLayer.Currency cur = BLayer.Currency.Get("USD");
                        RefundAmount = Math.Round(RefundAmount * cur.ConversionRate, 2, MidpointRounding.AwayFromZero);

                        if (amt >= (double)RefundAmount)
                        {
                            amt          = amt - (double)RefundAmount;
                            tryRefund    = RefundAmount;
                            RefundAmount = 0;
                        }
                        else
                        {
                            RefundAmount = RefundAmount - (decimal)amt;
                            tryRefund    = (decimal)amt;
                            amt          = 0;
                        }
                    }



                    totalServiceCharge = totalServiceCharge + serviceCharge;
                    tran.TryAmount    += tryRefund;
                    tran.ServiceCharge = tran.ServiceCharge + serviceCharge;

                    //tran.TryAmount = tryRefund;
                    //tran.ServiceCharge = tran.ServiceCharge + serviceCharge;
                    tran.TryTime     = DateTime.Today;
                    tran.TotalAmount = amt;
                    tran.Status      = CLayer.ObjectStatus.TransactionStatus.TryingForCanc;
                    BLayer.Transaction.UpdateAmountAndStatus(tran);
                    // if (RefundAmount <= 0) break;

                    countlist = countlist + 1;
                }
                //set totalservice charge and cancellation charge
                BLayer.Bookings.UpdateCharges(bookingId, cancellationCharge, (decimal)totalServiceCharge);
                BLayer.Bookings.SetRefund(bookingId, totalRefund - (decimal)totalServiceCharge);

                //save to booking refund
                //BLayer.Bookings.SaveBookingRefundAmt(bookingId, totalRefund - (decimal)totalServiceCharge, (int)CLayer.ObjectStatus.BookingChangeType.Cancel);

                foreach (CLayer.Transaction tran in refundable)
                {
                    try
                    {
                        //if (tran.ResponseCode != CLayer.Transaction.TRAN_SUCCESS)
                        //{
                        //    continue;
                        //}

                        if (tran.Status != CLayer.ObjectStatus.TransactionStatus.TryingForCanc)
                        {
                            continue;
                        }

                        if (Gatewaytype == (int)CLayer.ObjectStatus.Gateway.EBS)
                        {
                            if (SendRefund(tran))
                            {
                                //      if (tran.TotalAmount > 0)
                                //          tran.Status = CLayer.ObjectStatus.TransactionStatus.PartialRefund;
                                //       else
                                tran.Status    = CLayer.ObjectStatus.TransactionStatus.Refunded;
                                tran.TryAmount = 0;
                                BLayer.Transaction.UpdateAmountAndStatus(tran);
                            }
                        }
                        else if (Gatewaytype == (int)CLayer.ObjectStatus.Gateway.PayPal)
                        {
                            if (SendPayPalRefund(tran))
                            {
                                tran.Status    = CLayer.ObjectStatus.TransactionStatus.Refunded;
                                tran.TryAmount = 0;
                                BLayer.Transaction.UpdateAmountAndStatus(tran);
                            }
                        }
                    }
                    catch
                    { }
                }
            }
            else
            {
                //very less amount to refund which can be less than Rs.10
                BLayer.Transaction.RefundAllTransactions(bookingId);
            }
        }
Esempio n. 20
0
        public static void RefundAmount(long bookingId, decimal refundAmountAfterApplyingCancCharge, decimal cancellationCharge)
        {
            decimal RefundAmount = refundAmountAfterApplyingCancCharge;

            CLayer.Booking            detail     = BLayer.Bookings.GetDetails(bookingId);
            List <CLayer.Transaction> refundable = BLayer.Transaction.GetAllRefundable(bookingId);
            double serviceCharge      = 0;
            double totalServiceCharge = 0;

            CLayer.Property prp = BLayer.Property.GetCancellationCharges(BLayer.Bookings.GetPropertyId(bookingId));

            //found refund amount by reducing cancellation charge, service charge will be deducted once the transaction is done

            bool    CanCancel   = (RefundAmount > CLayer.Settings.TRANSACTION_MIN_AMOUNT);
            decimal totalRefund = RefundAmount;

            if (CanCancel)
            {
                //mark as trying
                double  amt       = 0;
                decimal tryRefund = 0;
                foreach (CLayer.Transaction tran in refundable)
                {
                    //(pPaymentId VARCHAR(12),pTryAmount DECIMAL(14,2), pTryTime DATETIME,pTotalAmount DECIMAL(14,2),pStatus INT)
                    serviceCharge = GetServiceCharge((CLayer.ObjectStatus.PaymentMethod)tran.PaymentType);
                    if (serviceCharge > 0)
                    {
                        serviceCharge = Math.Round((double)RefundAmount * serviceCharge / 100 * 2);
                        RefundAmount  = RefundAmount - (decimal)serviceCharge;
                    }
                    if (RefundAmount <= 0)
                    {
                        break;
                    }
                    amt = tran.TotalAmount; // -serviceCharge;
                    if (amt >= (double)RefundAmount)
                    {
                        amt          = amt - (double)RefundAmount;
                        tryRefund    = RefundAmount;
                        RefundAmount = 0;
                    }
                    else
                    {
                        RefundAmount = RefundAmount - (decimal)amt;
                        tryRefund    = (decimal)amt;
                        amt          = 0;
                    }
                    totalServiceCharge = totalServiceCharge + serviceCharge;
                    tran.TryAmount    += tryRefund;
                    tran.ServiceCharge = tran.ServiceCharge + serviceCharge;
                    tran.TryTime       = DateTime.Today;
                    tran.TotalAmount   = amt;
                    tran.Status        = CLayer.ObjectStatus.TransactionStatus.TryingForRefund;
                    BLayer.Transaction.UpdateAmountAndStatus(tran);
                }

                foreach (CLayer.Transaction tran in refundable)
                {
                    try
                    {
                        if (tran.Status != CLayer.ObjectStatus.TransactionStatus.TryingForRefund)
                        {
                            continue;
                        }
                        if (SendRefund(tran))
                        {
                            if (tran.TotalAmount > 0)
                            {
                                tran.Status = CLayer.ObjectStatus.TransactionStatus.PartialRefund;
                            }
                            else
                            {
                                tran.Status = CLayer.ObjectStatus.TransactionStatus.Refunded;
                            }
                            tran.TryAmount = 0;
                            BLayer.Transaction.UpdateAmountAndStatus(tran);
                        }
                    }
                    catch
                    { }
                }

                //set totalservice charge and cancellation charge
                BLayer.Bookings.UpdateCharges(bookingId, cancellationCharge, (decimal)totalServiceCharge);
                BLayer.Bookings.SetRefund(bookingId, totalRefund - (decimal)totalServiceCharge);

                //save to booking refund

                //BLayer.Bookings.SaveBookingRefundAmt(bookingId, totalRefund - (decimal)totalServiceCharge, (int)CLayer.ObjectStatus.BookingChangeType.Modify);
            }
        }
Esempio n. 21
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);
        }
Esempio n. 22
0
 public static long SaveBookingFor(CLayer.Booking data)
 {
     DataLayer.Booking bk = new DataLayer.Booking();
     return(bk.SaveBookingFor(data));
 }
Esempio n. 23
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);
        }