Ejemplo n.º 1
0
        public long SaveUser(CLayer.User data)
        {
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pUserId", DataPlug.DataType._BigInt, data.UserId));
            if (data.SalutationId == 0)
            {
                param.Add(Connection.GetParameter("pSalutationId", DataPlug.DataType._Int, DBNull.Value));
            }
            else
            {
                param.Add(Connection.GetParameter("pSalutationId", DataPlug.DataType._Int, data.SalutationId));
            }
            // param.Add(Connection.GetParameter("pBusinessName", DataPlug.DataType._Varchar, data.Businessname));
            param.Add(Connection.GetParameter("pFirstName", DataPlug.DataType._Varchar, data.FirstName));
            param.Add(Connection.GetParameter("pLastName", DataPlug.DataType._Varchar, data.LastName));
            param.Add(Connection.GetParameter("pDateOfBirth", DataPlug.DataType._Date, data.DateOfBirth));
            param.Add(Connection.GetParameter("pSex", DataPlug.DataType._Int, data.Sex));
            param.Add(Connection.GetParameter("pUserType", DataPlug.DataType._Int, data.UserTypeId));
            param.Add(Connection.GetParameter("pStatus", DataPlug.DataType._Int, data.Status));
            param.Add(Connection.GetParameter("pEmail", DataPlug.DataType._Varchar, data.Email));
            object result = Connection.ExecuteQueryScalar("userexternal_Save", param);

            return(Connection.ToLong(result));
        }
Ejemplo n.º 2
0
        public CLayer.User GetCountrUser(long userid)
        {
            CLayer.User user = null;
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pUserId", DataPlug.DataType._BigInt, userid));
            DataTable dt = Connection.GetTable("user_Get", param);

            if (dt.Rows.Count > 0)
            {
                user              = new CLayer.User();
                user.UserId       = Connection.ToLong(dt.Rows[0]["UserId"]);
                user.SalutationId = Connection.ToInteger(dt.Rows[0]["SalutationId"]);
                user.FirstName    = Connection.ToString(dt.Rows[0]["FirstName"]);
                user.LastName     = Connection.ToString(dt.Rows[0]["LastName"]);
                user.DateOfBirth  = Connection.ToDate(dt.Rows[0]["DateOfBirth"]);
                user.Sex          = Connection.ToInteger(dt.Rows[0]["Sex"]);
                user.UserTypeId   = Connection.ToInteger(dt.Rows[0]["UserType"]);
                user.Status       = Connection.ToInteger(dt.Rows[0]["Status"]);
                user.Email        = Connection.ToString(dt.Rows[0]["Email"]);
                user.CreatedDate  = Connection.ToDate(dt.Rows[0]["CreatedDate"]);
                user.Phone        = Connection.ToString(dt.Rows[0]["Phone"]);
                user.Mobile       = Connection.ToString(dt.Rows[0]["Mobile"]);
                user.Country      = Connection.ToString(dt.Rows[0]["Country"]);
            }
            return(user);
        }
Ejemplo n.º 3
0
        public List <CLayer.User> GetAllCorporateUsers(long corporateId)
        {
            List <CLayer.User>        result = new List <CLayer.User>();
            List <DataPlug.Parameter> param  = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pCorporateId", DataPlug.DataType._BigInt, corporateId));
            param.Add(Connection.GetParameter("pDeleteStatus", DataPlug.DataType._Int, CLayer.ObjectStatus.StatusType.Deleted));
            //corporate_GetUsers
            DataTable dt = Connection.GetTable("corporate_GetUsers", param);

            CLayer.User temp;
            foreach (DataRow dr in dt.Rows)
            {
                temp = new CLayer.User()
                {
                    Salutation          = Connection.ToString(dr["Salutation"]),
                    Email               = Connection.ToString(dr["Email"]),
                    FirstName           = Connection.ToString(dr["Firstname"]),
                    LastName            = Connection.ToString(dr["Lastname"]),
                    Status              = Connection.ToInteger(dr["Status"]),
                    UserId              = Connection.ToLong(dr["UserId"]),
                    UserTypeId          = Connection.ToInteger(dr["CorpUserType"]),
                    AssistedBookingFlag = Connection.ToInteger(dr["AssistedBooking_Flag"])//corporate user type :admin, staff
                };
                temp.Name = temp.Salutation + " " + temp.FirstName + " " + temp.LastName;
                result.Add(temp);
            }
            return(result);
        }
Ejemplo n.º 4
0
        public ActionResult Details(long?id)
        {
            Models.UserDetailModel details = null;
            CLayer.User            data    = BLayer.User.Get(id.Value);
            if (data != null)
            {
                details = new Models.UserDetailModel()
                {
                    UserId       = data.UserId,
                    SalutationId = data.SalutationId,
                    FirstName    = data.FirstName,
                    LastName     = data.LastName,
                    DateOfBirth  = data.DateOfBirth.ToShortDateString(),
                    Status       = data.Status,
                    Email        = data.Email,
                    CreatedDate  = data.CreatedDate,
                    DeletedDate  = data.DeletedDate,
                    LastLoginOn  = data.LastLoginOn,
                    Phone        = data.Phone,
                    Mobile       = data.Mobile,
                    PANNo        = data.PANNo
                };
            }
            CLayer.B2B b2b = BLayer.B2B.Get(id.Value);
            if (b2b != null)
            {
                details.MaxStaff = b2b.MaximumStaff;
                details.Name     = b2b.Name;
                details.PANNo    = b2b.PANNo;
            }

            CLayer.Address adrs = BLayer.Address.GetPrimaryOnUser(id.Value);
            if (adrs != null)
            {
                details.Address   = adrs.AddressText;
                details.AddressId = adrs.AddressId;
                details.State     = adrs.State;

                details.CountryId = adrs.CountryId;
                details.Phone     = adrs.Phone;
                details.Mobile    = adrs.Mobile;
                details.ZipCode   = adrs.ZipCode;
                details.CityId    = adrs.CityId;
                details.City      = adrs.City;
                if (adrs.CityId > 0)
                {
                    details.City   = BLayer.City.Get(adrs.CityId).Name;
                    details.CityId = adrs.CityId;
                }
                else
                {
                    if (adrs.City != null && adrs.City != "")
                    {
                        details.City = adrs.City;
                    }
                }
                details.LoadPlaces();
            }
            return(View(details));
        }
        public ActionResult SupplierUpdate(Models.UserDetailModel data)
        {
            CLayer.User usr = new CLayer.User()
            {
                UserId       = data.UserId,
                Businessname = data.Name,    //Businessname
                SalutationId = data.SalutationId,
                FirstName    = data.FirstName,
                LastName     = data.FirstName,
                Email        = data.Email
            };
            BLayer.User.Update(usr);

            CLayer.B2B b2b = new CLayer.B2B()
            {
                B2BId = data.UserId,
                Name  = data.Name,   //Businessname
                PropertyDescription = data.PropertyDescription,
                AvailableProperties = data.AvailableProperties
            };


            BLayer.B2B.Update(b2b);
            //if (data.UserId > 0)
            //{
            //    ViewData["B2BId"] = data.UserId;
            //}
            CLayer.Address adrs = new CLayer.Address()
            {
                AddressId   = data.AddressId,
                UserId      = data.UserId,
                AddressText = data.Address,
                //CityId = data.CityId,
                State       = data.State,
                CountryId   = data.CountryId,
                Phone       = data.Phone,
                ZipCode     = data.ZipCode,
                Mobile      = data.Mobile,
                AddressType = (int)CLayer.Address.AddressTypes.Primary
            };
            if (data.CityId > 0)
            {
                adrs.City   = BLayer.City.Get(data.CityId).Name;
                adrs.CityId = data.CityId;
            }
            else
            {
                if (data.City != null && data.City != "")
                {
                    adrs.City = data.City;
                }
            }


            BLayer.Address.Save(adrs);
            ViewBag.Message = "Your details updated successfully";
            return(RedirectToAction("SupplierDetails", new { id = data.UserId }));
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 8
0
        public long Update(CLayer.User data)
        {
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pUserId", DataPlug.DataType._BigInt, data.UserId));
            //param.Add(Connection.GetParameter("pBusinessname", DataPlug.DataType._Varchar, data.Businessname));
            param.Add(Connection.GetParameter("pFirstName", DataPlug.DataType._Varchar, data.FirstName));
            param.Add(Connection.GetParameter("pLastName", DataPlug.DataType._Varchar, data.LastName));
            param.Add(Connection.GetParameter("pEmail", DataPlug.DataType._Varchar, data.Email));
            object result = Connection.ExecuteQueryScalar("user_Update", param);

            return(Connection.ToLong(result));
        }
Ejemplo n.º 9
0
 public ActionResult Edit(Models.UserModel data)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CLayer.User pt = new CLayer.User()
             {
                 UserId       = data.UserId,
                 SalutationId = data.SalutationId,
                 FirstName    = data.FirstName,
                 LastName     = data.LastName,
                 DateOfBirth  = Convert.ToDateTime(data.DateOfBirth),
                 Sex          = data.Sex,
                 UserTypeId   = data.UserTypeId,
                 Status       = data.Status,
                 Email        = data.Email
             };
             long saved = BLayer.User.Save(pt);
             if (saved > 0)
             {
                 if (data.UserId == 0)
                 {
                     UserManager <StayBazar.Lib.Security.IdentityUser> UserManager = new UserManager <StayBazar.Lib.Security.IdentityUser>(new UserStore());
                     String userId            = User.Identity.GetUserId();
                     String newPassword       = BLayer.Settings.GetValue(CLayer.Settings.DEFAULT_PASSWORD);
                     String hashedNewPassword = UserManager.PasswordHasher.HashPassword(newPassword);
                     BLayer.User.SetPassword(saved, hashedNewPassword);
                 }
                 ViewBag.Saved = true;
                 return(RedirectToAction("Index"));
             }
             else
             {
                 ViewBag.Saved        = true;
                 ViewBag.ErrorMessage = "Other user with this EmailId exists.";
                 return(View("Edit", data));
             }
         }
         else
         {
             ViewBag.Saved = false;
             return(View("Edit", data));
         }
     }
     catch (Exception ex)
     {
         Common.LogHandler.HandleError(ex);
         return(Redirect("~/ErrorPage"));
     }
 }
Ejemplo n.º 10
0
        public CLayer.User getuserAddressdata(long userid)
        {
            CLayer.User user = null;
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pUserId", DataPlug.DataType._BigInt, userid));
            DataTable dt = Connection.GetTable("GetuserAddressdata", param);

            if (dt.Rows.Count > 0)
            {
                user       = new CLayer.User();
                user.Phone = Connection.ToString(dt.Rows[0]["Phone"]);
            }
            return(user);
        }
Ejemplo n.º 11
0
        public void SaveInfo(CLayer.User data, List <long> SbEntities)
        {
            string strgSbEntities = "";

            if (SbEntities != null)
            {
                if (SbEntities.Count > 0)
                {
                    strgSbEntities = string.Join(",", SbEntities);
                }
            }
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pUserId", DataPlug.DataType._BigInt, data.UserId));
            param.Add(Connection.GetParameter("pPhone", DataPlug.DataType._Varchar, data.Phone));
            param.Add(Connection.GetParameter("pSbEntities", DataPlug.DataType._Varchar, strgSbEntities));
            Connection.ExecuteQueryScalar("user_SaveInfo", param);
        }
Ejemplo n.º 12
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");
        }
 public ActionResult Details(long Id)
 {
     try
     {
         CLayer.B2B      data = BLayer.B2B.Get(Id);
         Models.B2BModel b2b  = new Models.B2BModel()
         {
             B2BId               = data.B2BId,
             UserId              = data.B2BId,
             Name                = data.Name,
             Email               = data.Email,
             UserType            = data.UserType,
             CompanyRegNo        = data.CompanyRegNo,
             ServiceTaxRegNo     = data.ServiceTaxRegNo,
             VATRegNo            = data.VATRegNo,
             RequestStatus       = data.RequestStatus,
             PropertyDescription = data.PropertyDescription,
             AvailableProperties = data.AvailableProperties,
             Addresses           = BLayer.Address.GetOnUser(data.B2BId)
         };
         b2b.BankDetails = new CLayer.BankAccount();
         b2b.BankDetails = BLayer.BankAccount.GetOnUser(data.B2BId);
         CLayer.User usr = BLayer.User.Get(Id);
         if (usr != null)
         {
             b2b.ContactName = usr.FirstName;
         }
         if (data.RequestStatus == (int)CLayer.ObjectStatus.StatusType.NotVerified ||
             data.RequestStatus == (int)CLayer.ObjectStatus.StatusType.Unread)
         {
             BLayer.B2B.SetStatus(Id, (int)CLayer.ObjectStatus.StatusType.Read);
         }
         return(View(b2b));
     }
     catch (Exception ex)
     {
         Common.LogHandler.HandleError(ex);
         return(Redirect("~/Admin/ErrorPage"));
     }
 }
Ejemplo n.º 14
0
        public CLayer.User Get(long userid)
        {
            CLayer.User user = null;
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pUserId", DataPlug.DataType._BigInt, userid));
            DataTable dt = Connection.GetTable("user_Get", param);

            if (dt.Rows.Count > 0)
            {
                user                               = new CLayer.User();
                user.UserId                        = Connection.ToLong(dt.Rows[0]["UserId"]);
                user.SalutationId                  = Connection.ToInteger(dt.Rows[0]["SalutationId"]);
                user.FirstName                     = Connection.ToString(dt.Rows[0]["FirstName"]);
                user.salesregion                   = Connection.ToString(dt.Rows[0]["SalesRegion"]);
                user.LastName                      = Connection.ToString(dt.Rows[0]["LastName"]);
                user.DateOfBirth                   = Connection.ToDate(dt.Rows[0]["DateOfBirth"]);
                user.Sex                           = Connection.ToInteger(dt.Rows[0]["Sex"]);
                user.UserTypeId                    = Connection.ToInteger(dt.Rows[0]["UserType"]);
                user.Status                        = Connection.ToInteger(dt.Rows[0]["Status"]);
                user.Email                         = Connection.ToString(dt.Rows[0]["Email"]);
                user.CreatedDate                   = Connection.ToDate(dt.Rows[0]["CreatedDate"]);
                user.Phone                         = Connection.ToString(dt.Rows[0]["Phone"]);
                user.Mobile                        = Connection.ToString(dt.Rows[0]["Mobile"]);
                user.OPSEmail                      = Connection.ToString(dt.Rows[0]["OPSEmail"]);
                user.MaximumDailyEntitlement       = Connection.ToInteger(dt.Rows[0]["MaximumDailyEntitlement"]);
                user.GradeID                       = Connection.ToInteger(dt.Rows[0]["GradeID"]);
                user.CustomerPaymentMode           = Connection.ToInteger(dt.Rows[0]["CustomerPaymentMode"]);
                user.CustomerPaymentModeCreditDays = Connection.ToDecimal(dt.Rows[0]["CustomerPaymentModeCreditDays"]);
                user.SbEntities                    = Connection.ToString(dt.Rows[0]["SbEntities"]);
                user.Address                       = Connection.ToString(dt.Rows[0]["Address"]);
                user.Country                       = Connection.ToString(dt.Rows[0]["Country"]);
                user.State                         = Connection.ToString(dt.Rows[0]["State"]);
                user.City                          = Connection.ToString(dt.Rows[0]["City"]);
                user.CostCentre                    = Connection.ToInteger(dt.Rows[0]["CostCentre"]);
                user.AssistedBookingFlag           = Connection.ToInteger(dt.Rows[0]["AssistedBooking_Flag"]);
            }
            return(user);
        }
Ejemplo n.º 15
0
        public long SaveCorporateUser(CLayer.User userDetails, long corporateId, int corporateUserType)
        {
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pUserId", DataPlug.DataType._BigInt, userDetails.UserId));
            param.Add(Connection.GetParameter("pCorporateId", DataPlug.DataType._BigInt, corporateId));
            param.Add(Connection.GetParameter("pCorporateUserType", DataPlug.DataType._Int, corporateUserType));
            param.Add(Connection.GetParameter("pSalutationId", DataPlug.DataType._Int, userDetails.SalutationId));
            param.Add(Connection.GetParameter("pFirstName", DataPlug.DataType._Varchar, userDetails.FirstName));
            param.Add(Connection.GetParameter("pLastName", DataPlug.DataType._Varchar, userDetails.LastName));
            param.Add(Connection.GetParameter("pDateOfBirth", DataPlug.DataType._Date, userDetails.DateOfBirth));
            param.Add(Connection.GetParameter("pSex", DataPlug.DataType._Int, userDetails.Sex));
            param.Add(Connection.GetParameter("pUserType", DataPlug.DataType._Int, userDetails.UserTypeId));
            param.Add(Connection.GetParameter("pStatus", DataPlug.DataType._Int, userDetails.Status));
            param.Add(Connection.GetParameter("pEmail", DataPlug.DataType._Varchar, userDetails.Email));
            param.Add(Connection.GetParameter("pMaximumDailyEntitlement", DataPlug.DataType._BigInt, userDetails.MaximumDailyEntitlement));
            param.Add(Connection.GetParameter("pGradeID", DataPlug.DataType._BigInt, userDetails.GradeID));
            param.Add(Connection.GetParameter("pCostCentre", DataPlug.DataType._BigInt, userDetails.CostCentre));
            object result = Connection.ExecuteQueryScalar("corporate_SaveUser", param);

            return(Connection.ToInteger(result));
        }
        public ActionResult SaveDetails(Models.CorporateUserModel data, string DdlApproverID, string ApproverOrdersList, string pB2BHotels)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                //CheckStaffLimit
                long cid = 0;
                long.TryParse(User.Identity.GetUserId(), out cid);

                int i = BLayer.B2BUser.B2B_CheckStaffLimit(cid);
                //if (i== 1)// if i is one only add new user here from admin settings
                //{
                if (data.UserId > 0)
                {
                }
                else
                {
                    if (!BLayer.User.IsUniqueEmail(data.UserId, data.Email))
                    {
                        return(View("_general"));
                    }
                }

                CLayer.User usr = new CLayer.User();
                usr.UserId                  = data.UserId;
                usr.FirstName               = data.FirstName;
                usr.LastName                = data.LastName;
                usr.SalutationId            = data.SalutationId;
                usr.Email                   = data.Email;
                usr.Status                  = data.StatusId;
                usr.MaximumDailyEntitlement = data.MaximumDailyEntitlement;
                usr.GradeID                 = data.GradeID;
                usr.CostCentre              = data.CostCentre;
                usr.UserTypeId              = (int)CLayer.Role.Roles.CorporateUser;
                //long cid = 0;
                long.TryParse(User.Identity.GetUserId(), out cid);
                long userId = BLayer.B2BUser.SaveCorporateUser(usr, cid, data.UserTypeId);
                if (userId < 0)
                {
                    return(View("_general", "-2"));
                }


                CLayer.Address address = new CLayer.Address()
                {
                    AddressId   = data.AddressId,
                    UserId      = userId,
                    AddressText = data.Address,
                    CityId      = data.CityId,
                    State       = data.State,
                    CountryId   = data.CountryId,
                    ZipCode     = data.ZipCode,
                    // Phone = data.Phone,
                    Mobile      = data.Mobile,
                    AddressType = (int)CLayer.Address.AddressTypes.Primary
                };
                if (data.City != null && data.City != "")
                {
                    address.City = data.City;
                }
                if (data.CityId > 0)
                {
                    address.City = BLayer.City.Get(data.CityId).Name;
                }
                address.AddressType = (int)CLayer.Address.AddressTypes.Primary;
                BLayer.Address.Save(address);

                //password save
                if (data.Password != "" && data.Password != null)
                {
                    if (userId > 0)
                    {
                        UserManager <StayBazar.Lib.Security.IdentityUser> usrmngr = new UserManager <StayBazar.Lib.Security.IdentityUser>(new UserStore());
                        String hashedNewPassword = usrmngr.PasswordHasher.HashPassword(data.Password);
                        BLayer.User.SetPassword(userId, hashedNewPassword);
                    }
                }
                //}

                BLayer.ApprovalOrder.DeleteB2bApproversRecords(data.UserId);

                //ApprovalOrder Status  ./Start
                CLayer.ApprovalOrder approvalOrder = new CLayer.ApprovalOrder();
                if (DdlApproverID != "" && ApproverOrdersList != "")
                {
                    string[] ApproverIDsArray        = DdlApproverID.Split(',');
                    string[] ApproverOrdersListArray = ApproverOrdersList.Split(',');

                    int arrayApproverID = 0;

                    for (int arrayApproverOrder = 0; arrayApproverOrder < ApproverOrdersListArray.Length; arrayApproverID++, arrayApproverOrder++)
                    {
                        approvalOrder.b2b_approver_id = data.B2BApproverID;
                        if (data.UserId > 0)
                        {
                            approvalOrder.user_id = data.UserId;
                        }
                        else
                        {
                            approvalOrder.user_id = cid;
                        }
                        approvalOrder.approver_id    = Convert.ToInt64(ApproverIDsArray[arrayApproverID]);
                        approvalOrder.approver_order = Convert.ToInt32(ApproverOrdersListArray[arrayApproverOrder]);
                        approvalOrder.created_by     = (int)cid;
                        BLayer.ApprovalOrder.SaveApprovalOrder(approvalOrder);
                    }
                }

                //  ./End

                //Manage b2b_hotels
                if (!string.IsNullOrEmpty(pB2BHotels.Replace("-", "")))
                {
                    SaveB2bHotels(data, pB2BHotels);
                }



                //Manage b2b_hotels end


                Models.CorporateModel mdata = InitialData();
                return(View("_List", mdata));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(View("_general"));
        }
        public ActionResult GetDetails(long id)
        {
            try
            {
                Session["id"] = id;

                Models.CorporateUserModel cm = new Models.CorporateUserModel();
                if (id != 0)
                {
                    CLayer.User usr = BLayer.User.Get(id);
                    if (usr != null)
                    {
                        long cid = 0;
                        long.TryParse(User.Identity.GetUserId(), out cid);
                        cm.UserId                  = id;
                        cm.id                      = id;
                        Session["id"]              = id;
                        cm.SalutationId            = usr.SalutationId;
                        cm.FirstName               = usr.FirstName;
                        cm.LastName                = usr.LastName;
                        cm.StatusId                = usr.Status;
                        cm.UserTypeId              = (int)BLayer.B2BUser.GetRole(id, cid);
                        cm.Email                   = usr.Email;
                        cm.Sex                     = usr.Sex;
                        cm.StatusId                = usr.Status;
                        cm.MaximumDailyEntitlement = usr.MaximumDailyEntitlement;
                        cm.GradeID                 = usr.GradeID;
                        cm.CostCentre              = usr.CostCentre;
                        List <CLayer.Address> addr = BLayer.Address.GetOnUser(id);
                        if (addr.Count > 0)
                        {
                            cm.AddressId = addr[0].AddressId;
                            cm.Address   = addr[0].AddressText;
                            cm.Phone     = addr[0].Phone;
                            cm.Mobile    = addr[0].Mobile;
                            cm.State     = addr[0].State;
                            cm.CityId    = addr[0].CityId;
                            cm.City      = addr[0].City;
                            cm.CountryId = addr[0].CountryId;
                        }
                        cm.LoadPlaces();
                        if (addr[0].CityId > 0)
                        {
                            cm.CityId = addr[0].CityId;
                        }
                        else
                        {
                            cm.City = addr[0].City;
                        }
                    }
                    cm.ApprovalOrder = BLayer.ApprovalOrder.GetAssignedB2bApproversList(id);
                    cm.B2BHotelsList = BLayer.B2BUser.GetAssignedB2bHotelsList(id);
                }
                return(View("_Details", cm));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                Redirect("~/ErrorPage");
            }
            return(View());
        }
Ejemplo n.º 18
0
        public ActionResult Edit(int id)
        {
            try
            {
                Admin.Models.HostModel hostModel = new Admin.Models.HostModel();
                if (id != 0)
                {
                    CLayer.User user = BLayer.User.Get(id);
                    if (user != null)
                    {
                        hostModel.UserId       = user.UserId;
                        hostModel.SalutationId = user.SalutationId;
                        hostModel.FirstName    = user.FirstName;
                        hostModel.SalesRegion  = user.salesregion;
                        hostModel.LastName     = user.LastName;
                        hostModel.DateOfBirth  = user.DateOfBirth.ToShortDateString();
                        hostModel.Sex          = user.Sex;
                        hostModel.UserTypeId   = user.UserTypeId;
                        hostModel.Status       = user.Status;
                        hostModel.Email        = user.Email;
                        hostModel.OPSEmail     = user.OPSEmail;
                        hostModel.CreatedDate  = user.CreatedDate;
                        List <CLayer.Address> addr = BLayer.Address.GetOnUser(id);
                        if (addr.Count > 0)
                        {
                            hostModel.AddressId = addr[0].AddressId;
                            hostModel.Address   = addr[0].AddressText;
                            hostModel.Phone     = addr[0].Phone;
                            hostModel.Mobile    = addr[0].Mobile;
                            hostModel.State     = addr[0].State;
                            hostModel.CityId    = addr[0].CityId;
                            hostModel.City      = addr[0].City;
                            hostModel.CountryId = addr[0].CountryId;
                            hostModel.ZipCode   = addr[0].ZipCode;
                            hostModel.Mobile    = addr[0].Mobile;
                        }
                        //else
                        //{
                        //    hostModel.CityId = 7;
                        //    hostModel.State =3;
                        //    hostModel.CountryId = 1;
                        //}

                        hostModel.LoadPlacesStaff();
                        if (addr.Count > 0)
                        {
                            if (addr[0].CityId > 0)
                            {
                                hostModel.CityId = addr[0].CityId;
                            }
                            else
                            {
                                hostModel.City = addr[0].City;
                            }
                        }


                        hostModel.SbEntities       = hostModel.SbEntityList.Select(c => c.EntityId).ToList();
                        hostModel.SelectedSbEntity = new List <CLayer.SBEntity>();
                        if (user.SbEntities != null)
                        {
                            if (user.SbEntities != "")
                            {
                                List <long> sbentylst = new List <long>(Array.ConvertAll(user.SbEntities.Split(','), long.Parse));
                                hostModel.SbEntities = hostModel.SbEntityList.Where(p => !sbentylst.Any(p2 => p2 == p.EntityId)).Select(c => c.EntityId).ToList();
                            }
                        }
                        //get phone
                        CLayer.User userAddressdata = BLayer.User.getuserAddressdata(id);
                        ViewBag.Head = user.FirstName + " " + user.LastName;
                        if (userAddressdata != null)
                        {
                            hostModel.Phone = userAddressdata.Phone;
                        }
                    }
                }
                return(View("Edit", hostModel));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/Admin/ErrorPage"));
            }
        }
        //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);
        }
Ejemplo n.º 20
0
        public async Task <bool> SendMailInvoice(long OfflineBookingId)
        {
            string Filename = "";
            // send mail to customer -- after save
            string msg = await GetMailBody(OfflineBookingId);

            Common.Mailer ml = new Common.Mailer();
            System.Net.Mail.MailMessage mail     = new System.Net.Mail.MailMessage();
            CLayer.OfflineBooking       booking  = BLayer.OfflineBooking.GetAllDetailsById(OfflineBookingId);
            CLayer.OfflineBooking       customer = new CLayer.OfflineBooking();

            int bookingType = BLayer.OfflineBooking.GetBookingType(OfflineBookingId);

            if (bookingType == (int)CLayer.ObjectStatus.OfflineBookingType.TAC)
            {
                //Mail To Supplier
                if (OfflineBookingId > 0)
                {
                    CLayer.OfflineBooking OfflinePropertydata = BLayer.OfflineBooking.GetAllpropertyDetails(OfflineBookingId);
                    if (OfflinePropertydata != null)
                    {
                        if (OfflinePropertydata.SupplierEmail != null && OfflinePropertydata.SupplierEmail != "")
                        {
                            mail.To.Add(OfflinePropertydata.SupplierEmail);
                        }
                    }
                }
                string BccEmailsforSup = BLayer.Settings.GetValue(CLayer.Settings.CC_SUPPLIERCOMMUNICATION);
                if (BccEmailsforSup.Trim() != "")
                {
                    string[] emails = BccEmailsforSup.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mail.CC.Add(emails[i]);
                    }
                }
            }
            else
            {
                //Mail To Customer
                if (OfflineBookingId > 0)
                {
                    customer = BLayer.OfflineBooking.GetAllCustomerDetails(OfflineBookingId);
                }
                if (customer != null)
                {
                    if (customer.CustomerEmail != "")
                    {
                        mail.To.Add(customer.CustomerEmail);
                    }
                }
                #region for corporate
                //for corporate admins
                //long userid = BLayer.User.GetUserId(customer.CustomerEmail);
                //if (userid > 0)
                //{
                //    CLayer.Role.Roles rle = BLayer.User.GetRole(userid);
                //    if (rle == CLayer.Role.Roles.CorporateUser)
                //    {
                //        long cid = BLayer.B2B.GetCorporateIdOfUser(userid);
                //    }
                //}
                //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);
                //    }
                //}
                //mail.To.Add(BLayer.Settings.GetValue(CLayer.Settings.SUPPORT_EMAIL));
                #endregion
                string BccEmailsforcus = BLayer.Settings.GetValue(CLayer.Settings.CC_CUSTOMERCOMMUNICATION);
                if (BccEmailsforcus.Trim() != "")
                {
                    string[] emails = BccEmailsforcus.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mail.CC.Add(emails[i]);
                    }
                }
            }



            CLayer.Invoice data = BLayer.Invoice.GetInvoiceByOfflineBooking(OfflineBookingId);

            if (data != null)
            {
                mail.Subject = "Invoice against Booking ID: " + booking.ConfirmationNumber + ", Invoice No. " + data.InvoiceNumber;
            }

            mail.Body       = msg;
            mail.IsBodyHtml = true;



            //add atachment
            try
            {
                Areas.Admin.Models.Invoice inv = new Areas.Admin.Models.Invoice();

                if (data != null)
                {
                    inv.InvoiceId        = data.InvoiceId;
                    inv.OfflineBookingId = data.OfflineBookingId;
                    inv.IsMailed         = (data.MailedDate <= DateTime.Today);
                    inv.HtmlSection1     = data.HtmlSection1;
                    inv.HtmlSection2     = data.HtmlSection2;
                    inv.HtmlSection3     = data.HtmlSection3;

                    ViewAsPdf v = new ViewAsPdf("~/Areas/Admin/Views/ManageOfflineBooking/Mail.cshtml", inv)
                    {
                        PageMargins     = new Rotativa.Options.Margins(1, 1, 1, 1),
                        PageOrientation = Rotativa.Options.Orientation.Portrait,
                        PageSize        = Rotativa.Options.Size.Letter
                    };
                    string newdirectory = "Files\\Temp\\" + inv.InvoiceId;
                    if (!Directory.Exists(Server.MapPath("~") + "\\" + newdirectory))
                    {
                        Directory.CreateDirectory(Server.MapPath("~") + "\\" + newdirectory);
                    }
                    Filename = Server.MapPath("~") + "\\" + newdirectory + "\\" + "Invoice_" + data.InvoiceNumber + ".pdf";
                    var byteArray  = v.BuildPdf(ControllerContext);
                    var fileStream = new FileStream(Filename, FileMode.Create, FileAccess.Write);
                    fileStream.Write(byteArray, 0, byteArray.Length);
                    fileStream.Close();
                    fileStream.Dispose();

                    // System.Net.Mail.Attachment attachment;
                    Attachment attacht = new Attachment(Filename, MediaTypeNames.Application.Octet);
                    mail.Attachments.Add(attacht);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }


            string AccountMail = BLayer.Settings.GetValue(CLayer.Settings.ACCOUNT_EMAILS);
            if (AccountMail != "")
            {
                string[] Accemails = AccountMail.Split(',');
                for (int i = 0; i < Accemails.Length; ++i)
                {
                    mail.CC.Add(Accemails[i]);
                }
            }



            //send to ops mail
            string SalesPersonOPSMails = "";
            if (OfflineBookingId > 0)
            {
                CLayer.OfflineBooking OffdataStaff = BLayer.OfflineBooking.GetAllDetailsById(OfflineBookingId);
                if (OffdataStaff != null)
                {
                    if (OffdataStaff.SalesPersonId > 0)
                    {
                        CLayer.User usrstaff = BLayer.User.Get(OffdataStaff.SalesPersonId);
                        if (usrstaff != null)
                        {
                            if (usrstaff.OPSEmail != null && usrstaff.OPSEmail != "")
                            {
                                SalesPersonOPSMails = usrstaff.OPSEmail;
                            }
                        }
                    }
                }
            }
            if (SalesPersonOPSMails != "")
            {
                string CcOPSEmails = SalesPersonOPSMails.Trim();
                if (CcOPSEmails != "")
                {
                    string[] emails = CcOPSEmails.Split(',');
                    for (int i = 0; i < emails.Length; ++i)
                    {
                        mail.CC.Add(emails[i]);
                    }
                }
            }

            try
            {
                await ml.SendMailAsyncForBooking(mail, Common.Mailer.MailType.Reservation);
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
Ejemplo n.º 21
0
 public static long Save(CLayer.User data)
 {
     DataLayer.User user = new DataLayer.User();
     data.Validate();
     return(user.Save(data));
 }
Ejemplo n.º 22
0
        public ActionResult Update(Models.UserDetailModel data)
        {
            if (ModelState.IsValid)
            {
                CLayer.User usr = new CLayer.User()
                {
                    UserId       = data.UserId,
                    SalutationId = data.SalutationId,
                    FirstName    = data.FirstName,
                    LastName     = data.FirstName,
                    Businessname = data.Name,//Businessname
                    Email        = data.Email
                };
                long UserId = BLayer.User.Update(usr);
                if (UserId > 0)
                {
                    CLayer.B2B b2b = new CLayer.B2B()
                    {
                        B2BId = data.UserId,
                        Name  = data.Name,//Businessname
                        ContactDesignation = data.ContactDesignation
                    };
                    BLayer.B2B.Update(b2b);

                    CLayer.Address adrs = new CLayer.Address()
                    {
                        AddressId   = data.AddressId,
                        UserId      = data.UserId,
                        AddressText = data.Address,
                        // CityId = data.CityId,
                        State       = data.State,
                        CountryId   = data.CountryId,
                        Phone       = data.Phone,
                        ZipCode     = data.ZipCode,
                        Mobile      = data.Mobile,
                        AddressType = (int)CLayer.Address.AddressTypes.Normal
                    };


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

                    //billing address Save
                    CLayer.Address BillingAddress;
                    if (!data.IsClicked)
                    {
                        BillingAddress = new CLayer.Address()
                        {
                            AddressId   = data.BillingAddressId,
                            AddressText = data.BillingAddress,
                            ZipCode     = data.BillingZipCode,
                            UserId      = data.UserId,
                            CityId      = data.BillingCityId,
                            State       = data.BillingState,
                            CountryId   = data.BillingCountryId,
                            Phone       = data.Phone,
                            Mobile      = data.Mobile,
                            AddressType = (int)CLayer.Address.AddressTypes.Primary
                        };
                        if (data.BillingCity != null && data.BillingCity != "")
                        {
                            BillingAddress.City = data.BillingCity;
                        }
                        if (data.BillingCityId > 0)
                        {
                            BillingAddress.City = BLayer.City.Get(data.BillingCityId).Name;
                        }
                        BLayer.Address.Save(BillingAddress);
                    }
                    else
                    {
                        BillingAddress = new CLayer.Address()
                        {
                            AddressId   = data.BillingAddressId,
                            AddressText = data.Address,
                            UserId      = data.UserId,
                            ZipCode     = data.ZipCode,
                            CityId      = data.CityId,
                            City        = data.City,
                            State       = data.State,
                            CountryId   = data.CountryId,
                            Phone       = data.Phone,
                            Mobile      = data.Mobile,
                            AddressType = (int)CLayer.Address.AddressTypes.Primary
                        };
                        if (data.City != null && data.City != "")
                        {
                            BillingAddress.City = data.City;
                        }
                        if (data.CityId > 0)
                        {
                            BillingAddress.City = BLayer.City.Get(data.CityId).Name;
                        }
                        BLayer.Address.Save(BillingAddress);
                    }

                    ViewBag.Message = "Your details updated successfully";
                    return(RedirectToAction("Details", new { id = data.UserId }));
                }
                else
                {
                    ViewBag.Message = "The email id already used by someone else";
                }
            }
            else
            {
                var    errors = ModelState.Values.SelectMany(v => v.Errors);
                string err    = "";
                foreach (ModelError me in errors)
                {
                    err += me.ErrorMessage.ToString();
                }
                ViewBag.Message = err;
            }
            return(View("Details", data));
        }
Ejemplo n.º 23
0
        public ActionResult Details(long id)
        {
            Models.UserDetailModel details = null;
            CLayer.User            data    = BLayer.User.Get(id);
            if (data != null)
            {
                // details.FullName = data.FirstName + data.LastName;
                details = new Models.UserDetailModel()
                {
                    UserId                        = data.UserId,
                    SalutationId                  = data.SalutationId,
                    FirstName                     = data.FirstName,
                    LastName                      = data.LastName,
                    DateOfBirth                   = data.DateOfBirth.ToShortDateString(),
                    Status                        = data.Status,
                    Email                         = data.Email,
                    CreatedDate                   = data.CreatedDate,
                    DeletedDate                   = data.DeletedDate,
                    LastLoginOn                   = data.LastLoginOn,
                    CustomerPaymentMode           = data.CustomerPaymentMode,
                    CustomerPaymentModeCreditDays = data.CustomerPaymentModeCreditDays
                };
            }
            CLayer.B2B b2b = BLayer.B2B.Get(id);
            if (b2b != null)
            {
                details.MaxStaff     = b2b.MaximumStaff;
                details.Name         = b2b.Name;
                details.CreditPeriod = b2b.CreditPeriod;
            }
            CLayer.Address adrs = BLayer.Address.GetPrimaryOnUser(id);
            if (adrs != null)
            {
                details.Address   = adrs.AddressText;
                details.AddressId = adrs.AddressId;
                details.State     = adrs.State;

                details.CountryId = adrs.CountryId;
                details.Phone     = adrs.Phone;
                details.Mobile    = adrs.Mobile;
                details.ZipCode   = adrs.ZipCode;
                if (adrs.CityId > 0)
                {
                    details.City   = BLayer.City.Get(adrs.CityId).Name;
                    details.CityId = adrs.CityId;
                }
                else
                {
                    if (adrs.City != null && adrs.City != "")
                    {
                        details.City = adrs.City;
                    }
                }
            }


            CLayer.Address BillingAddress = BLayer.Address.GetBillingAddress(id);
            if (BillingAddress != null)
            {
                details.BillingAddressType = BillingAddress.BillingAddressType;
                details.BillingAddressId   = BillingAddress.BillingAddressId;
                details.BillingAddress     = BillingAddress.BillingAddress;
                details.BillingCityId      = BillingAddress.BillingCityId;
                details.BillingState       = BillingAddress.BillingState;
                details.BillingCity        = BillingAddress.BillingCity;
                details.BillingCountryId   = BillingAddress.BillingCountryId;
                details.BillingZipCode     = BillingAddress.BillingZipCode;
                details.IsClicked          = false;
            }
            else
            {
                details.BillingAddress     = details.Address;
                details.BillingAddressId   = 0;
                details.BillingAddress     = details.Address;
                details.BillingCityId      = details.CityId;
                details.BillingCity        = details.City;
                details.BillingState       = details.State;
                details.BillingCountryId   = details.CountryId;
                details.Phone              = details.Phone;
                details.Mobile             = details.Mobile;
                details.BillingAddressType = (int)CLayer.Address.AddressTypes.Primary;
                details.BillingZipCode     = details.ZipCode;
                details.IsClicked          = true;
            }

            if (details.BillingZipCode == details.ZipCode && details.BillingAddress == details.Address && details.BillingCityId == details.CityId && details.BillingCity == details.City && details.BillingState == details.State && details.BillingCountryId == details.CountryId)
            {
                details.IsClicked = true;
            }



            details.LoadPlaces();

            return(View("~/Areas/Admin/Views/Corporate/Details.cshtml", details));
        }
Ejemplo n.º 24
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);
        }
        public ActionResult Update(Models.UserDetailModel data)
        {
            if (ModelState.IsValid)
            {
                CLayer.User usr = new CLayer.User()
                {
                    UserId       = data.UserId,
                    Businessname = data.Name,//Businessname
                    SalutationId = data.SalutationId,
                    FirstName    = data.FirstName,
                    LastName     = data.FirstName,
                    Email        = data.Email
                };
                BLayer.User.Update(usr);

                CLayer.B2B b2b = new CLayer.B2B()
                {
                    B2BId = data.UserId,
                    Name  = data.Name,//Businessname
                    PANNo = data.PANNo
                };
                BLayer.B2B.Update(b2b);

                CLayer.Address adrs = new CLayer.Address()
                {
                    AddressId   = data.AddressId,
                    UserId      = data.UserId,
                    AddressText = data.Address,
                    //CityId = data.CityId,
                    State       = data.State,
                    CountryId   = data.CountryId,
                    Phone       = data.Phone,
                    ZipCode     = data.ZipCode,
                    Mobile      = data.Mobile,
                    AddressType = (int)CLayer.Address.AddressTypes.Primary
                };
                if (data.CityId > 0)
                {
                    adrs.City   = BLayer.City.Get(data.CityId).Name;
                    adrs.CityId = data.CityId;
                }
                else
                {
                    if (data.City != null && data.City != "")
                    {
                        adrs.City = data.City;
                    }
                }


                BLayer.Address.Save(adrs);
                ViewBag.Message = "Your details updated successfully";
                return(RedirectToAction("Details", new { id = data.UserId, B2bId = data.AffiliateId }));
            }
            else
            {
                var    errors = ModelState.Values.SelectMany(v => v.Errors);
                string err    = "";
                foreach (ModelError me in errors)
                {
                    err += me.ErrorMessage.ToString();
                }
                ViewBag.Message = err;
            }
            return(View("Details", data));
        }
Ejemplo n.º 26
0
 public static void SaveInfo(CLayer.User data, List <long> SbEntities)
 {
     DataLayer.User user = new DataLayer.User();
     user.SaveInfo(data, SbEntities);
 }
Ejemplo n.º 27
0
        public ActionResult Edit(HostModel data)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    CLayer.User pt = new CLayer.User()
                    {
                        UserId       = data.UserId,
                        SalutationId = data.SalutationId,
                        FirstName    = data.FirstName,
                        LastName     = data.LastName,
                        DateOfBirth  = Convert.ToDateTime(data.DateOfBirth),
                        salesregion  = data.SalesRegion,
                        Sex          = data.Sex,
                        UserTypeId   = data.UserTypeId,
                        Status       = data.Status,
                        Email        = data.Email,
                        OPSEmail     = data.OPSEmail
                    };
                    long saved = BLayer.User.Save(pt);

                    CLayer.Address address = new CLayer.Address()
                    {
                        AddressId   = data.AddressId,
                        UserId      = data.UserId,
                        AddressText = data.Address,
                        CityId      = data.CityId,
                        State       = data.State,
                        CountryId   = data.CountryId,
                        ZipCode     = data.ZipCode,
                        Mobile      = data.Mobile,
                        AddressType = (int)CLayer.Address.AddressTypes.Primary
                    };
                    if (data.City != null && data.City != "")
                    {
                        address.City = data.City;
                    }
                    if (data.CityId > 0)
                    {
                        address.City = BLayer.City.Get(data.CityId).Name;
                    }
                    address.AddressType = (int)CLayer.Address.AddressTypes.Primary;
                    BLayer.Address.Save(address);

                    //update phone
                    pt.Phone  = data.Phone;
                    pt.UserId = saved;
                    List <long> sbentylst = new List <long>();
                    if (data.SbEntities != null)
                    {
                        sbentylst = data.SbEntityList.Where(p => !data.SbEntities.Any(p2 => p2 == p.EntityId)).Select(c => c.EntityId).ToList();
                    }
                    else
                    {
                        sbentylst = data.SbEntityList.Select(c => c.EntityId).ToList();
                    }
                    BLayer.User.SaveInfo(pt, sbentylst);


                    if (saved > 0)
                    {
                        if (data.UserId == 0)
                        {
                            UserManager <StayBazar.Lib.Security.IdentityUser> usrmngr = new UserManager <StayBazar.Lib.Security.IdentityUser>(new UserStore());
                            String userId = User.Identity.GetUserId();

                            String newPassword       = BLayer.Settings.GetValue(CLayer.Settings.DEFAULT_PASSWORD);
                            String hashedNewPassword = usrmngr.PasswordHasher.HashPassword(newPassword);
                            BLayer.User.SetPassword(saved, hashedNewPassword);
                        }
                        else
                        {
                            if (data.PasswordHash != null)
                            {
                                UserManager <StayBazar.Lib.Security.IdentityUser> usrmngr = new UserManager <StayBazar.Lib.Security.IdentityUser>(new UserStore());

                                String newPassword       = data.PasswordHash;
                                String hashedNewPassword = usrmngr.PasswordHasher.HashPassword(newPassword);
                                BLayer.User.SetPassword(saved, hashedNewPassword);
                            }
                        }
                        if (data.UserTypeId == (int)CLayer.Role.Roles.SalesPerson || data.UserTypeId == 16)
                        {
                            BLayer.User.SaveSalesRegion(saved, pt.salesregion);
                        }
                        BLayer.User.AddUserRole(saved, data.UserTypeId);
                        ViewBag.Saved = true;
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ViewBag.Saved        = false;
                        ViewBag.ErrorMessage = "Other user with this EmailId exists.";
                        ViewBag.Head         = "New Staff";
                        return(View("Edit", data));
                    }
                }
                else
                {
                    if (data.UserId == 0)
                    {
                        ViewBag.Head = "New Staff";
                    }
                    ViewBag.Saved = false;
                    return(View("Edit", data));
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/Admin/ErrorPage"));
            }
        }
Ejemplo n.º 28
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);
        }
Ejemplo n.º 29
0
 public static long SaveCorporateUser(CLayer.User userDetails, long corporateId, int corporateUserType)
 {
     DataLayer.B2BUser b2buser = new DataLayer.B2BUser();
     return(b2buser.SaveCorporateUser(userDetails, corporateId, corporateUserType));
 }
Ejemplo n.º 30
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);
        }