Esempio n. 1
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));
        }
Esempio n. 2
0
        public CLayer.Address GetOnUserId(long UserId, int Addresstype)
        {
            CLayer.Address            result = null;
            List <DataPlug.Parameter> param  = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pUserId", DataPlug.DataType._BigInt, UserId));
            param.Add(Connection.GetParameter("pType", DataPlug.DataType._Int, Addresstype));
            DataTable dt = Connection.GetTable("address_GetOnUserType", param);

            if (dt.Rows.Count > 0)
            {
                result             = new CLayer.Address();
                result.AddressId   = Connection.ToLong(dt.Rows[0]["AddressId"]);
                result.UserId      = Connection.ToLong(dt.Rows[0]["UserId"]);
                result.CityId      = Connection.ToInteger(dt.Rows[0]["CityId"]);
                result.AddressText = Connection.ToString(dt.Rows[0]["Address"]);
                result.City        = Connection.ToString(dt.Rows[0]["City"]);
                result.State       = Connection.ToInteger(dt.Rows[0]["State"]);
                result.CountryId   = Connection.ToInteger(dt.Rows[0]["Country"]);
                result.ZipCode     = Connection.ToString(dt.Rows[0]["ZipCode"]);
                result.Phone       = Connection.ToString(dt.Rows[0]["Phone"]);
                result.Mobile      = Connection.ToString(dt.Rows[0]["Mobile"]);
                result.AddressType = Connection.ToInteger(dt.Rows[0]["Type"]);
            }
            return(result);
        }
        public ActionResult GetDetails(string Email)
        {
            OfflinePaymentModel model = new OfflinePaymentModel();
            long UserId = BLayer.User.GetUserId(Email);

            if (UserId > 0)
            {
                CLayer.Address byAddress = BLayer.Address.GetAddressOnUserId(UserId);
                CLayer.Address adrs      = BLayer.Address.GetPrimaryOnUser(UserId);
                if (byAddress != null && adrs != null)
                {
                    model.Name      = byAddress.Firstname;
                    model.Email     = byAddress.Email;
                    model.Mobile    = adrs.Mobile;
                    model.CityId    = adrs.CityId;
                    model.State     = adrs.State;
                    model.CountryId = adrs.CountryId;
                    model.ZipCode   = adrs.ZipCode;
                    model.Address   = adrs.AddressText;
                    model.LoadPlaces();
                    return(View("_Details", model));
                }
                else
                {
                    return(View("_Details", model));
                }
            }
            else
            {
                return(View("_Details", model));
            }
        }
Esempio n. 4
0
        public CLayer.Address GetPrimaryOnUser(long UserId)
        {
            CLayer.Address            address = null;
            List <DataPlug.Parameter> param   = new List <DataPlug.Parameter>();

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

            if (dt.Rows.Count > 0)
            {
                address             = new CLayer.Address();
                address.AddressId   = Connection.ToLong(dt.Rows[0]["AddressId"]);
                address.UserId      = Connection.ToLong(dt.Rows[0]["UserId"]);
                address.AddressText = Connection.ToString(dt.Rows[0]["Address"]);
                address.CityId      = Connection.ToInteger(dt.Rows[0]["CityId"]);
                address.City        = Connection.ToString(dt.Rows[0]["City"]);
                address.State       = Connection.ToInteger(dt.Rows[0]["State"]);
                address.CountryId   = Connection.ToInteger(dt.Rows[0]["Country"]);
                address.ZipCode     = Connection.ToString(dt.Rows[0]["ZipCode"]);
                address.Phone       = Connection.ToString(dt.Rows[0]["Phone"]);
                address.Mobile      = Connection.ToString(dt.Rows[0]["Mobile"]);
                address.AddressType = Connection.ToInteger(dt.Rows[0]["Type"]);
            }
            return(address);
        }
        public ActionResult Index()
        {
            long UserId = GetUserId();

            CLayer.Address      byAddress = BLayer.Address.GetAddressOnUserId(UserId);
            CLayer.Address      adrs      = BLayer.Address.GetPrimaryOnUser(UserId);
            PaymentRequestModel model     = new PaymentRequestModel();

            if (byAddress != null && adrs != null)
            {
                model.Name      = byAddress.Firstname;
                model.Email     = byAddress.Email;
                model.Mobile    = adrs.Mobile;
                model.CityId    = adrs.CityId;
                model.City      = adrs.City;
                model.State     = adrs.State;
                model.CountryId = adrs.CountryId;
                model.ZipCode   = adrs.ZipCode;
                model.Address   = adrs.AddressText;
                return(View(model));
            }
            else
            {
                return(View(model));
            }
        }
        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 }));
        }
Esempio n. 7
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 ActionResult SaveDetails(Models.SaveBookingUserModel data)
        {
            try
            {
                CLayer.Address adr = new CLayer.Address();
                adr.AddressId   = data.AddressId;
                adr.AddressType = (int)CLayer.Address.AddressTypes.Normal;
                adr.AddressText = data.Address;
                if (data.City != null && data.City != "")
                {
                    adr.City = data.City;
                }
                else
                {
                    if (data.CityId > 0)
                    {
                        adr.City = BLayer.City.Get(data.CityId).Name;
                    }
                }
                adr.State     = data.State;
                adr.CountryId = data.CountryId;
                adr.Phone     = data.Phone;
                adr.Mobile    = data.Mobile;
                // adr.UserId = 1;
                adr.CityId = data.CityId;
                //  adr.City = data.City;
                adr.ZipCode = data.ZipCode;

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

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


                long ForBookingUserId = BLayer.Bookings.SaveBookingFor(usr); //add new for booking user
                long bookingId        = BLayer.Bookings.GetCartId(userId);   //getbookingId
                BLayer.Bookings.UpdateBooking(ForBookingUserId, bookingId);  //update bookingitems ForuserId
                return(RedirectToAction("Index", "Booking"));
            } catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/ErrorPage"));
            }
        }
Esempio n. 9
0
        public ActionResult SaveAddress(Models.GuestAddressModel data)
        {
            try
            {
                long userId = 0;
                if (Session[CLayer.ObjectStatus.GUEST_ID_SESSION] != null)
                {
                    userId = (long)Session[CLayer.ObjectStatus.GUEST_ID_SESSION];
                }
                else
                {
                    return(RedirectToAction("Index", "Continue"));
                }

                Session["LoggedInUser"]  = Convert.ToInt64(userId);
                Session["LoggedInEmail"] = BLayer.User.GetEmail(Convert.ToInt64(Session["LoggedInUser"]));
                Session["UserName"]      = data.FirstName + " " + data.Lastname;

                BLayer.User.SetName(userId, data.FirstName, data.Lastname);
                CLayer.Address ad = BLayer.Address.GetOnUserId(userId, (int)CLayer.Address.AddressTypes.Primary);
                if (ad == null)
                {
                    ad           = new CLayer.Address();
                    ad.UserId    = userId;
                    ad.AddressId = 0;
                }
                ad.AddressText = data.Address;
                ad.City        = data.City;
                ad.CityId      = data.CityId;
                ad.State       = data.State;
                ad.CountryId   = data.CountryId;
                ad.Mobile      = ad.Mobile;
                ad.Phone       = ad.Phone;
                ad.ZipCode     = data.Pincode;
                if (data.City != null && data.City != "")
                {
                    ad.City = data.City;
                }
                if (data.CityId > 0)
                {
                    ad.City = BLayer.City.Get(data.CityId).Name;
                }
                ad.AddressType = (int)CLayer.Address.AddressTypes.Primary;
                BLayer.Address.Save(ad);
                return(RedirectToAction("Book", "Booking"));
            }catch (Exception ex)
            { Common.LogHandler.HandleError(ex); }
            return(RedirectToAction("Book", "Booking"));
        }
Esempio n. 10
0
        //   public string OrderNo { get; set; }
        public BookingModel()
        {
            Items          = new List <CLayer.BookingItem>();
            OrderedBy      = new CLayer.Address();
            Forbookings    = new BookingForUserModel();
            BookingDetails = new CLayer.Booking();
            offeritems     = new CLayer.Offers();
            Supplier       = new CLayer.User();
            ForPrint       = false;
            ForPdf         = false;

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

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

            CorporateUserName = new SelectList(CorporateUserList, "UserId", "FirstName");
        }
Esempio n. 11
0
        public long BillingAddress(CLayer.Address data)
        {
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pAddressId", DataPlug.DataType._BigInt, data.AddressId));
            param.Add(Connection.GetParameter("pUserId", DataPlug.DataType._BigInt, data.UserId));
            param.Add(Connection.GetParameter("pAddress", DataPlug.DataType._Varchar, data.AddressText));
            param.Add(Connection.GetParameter("pCityId", DataPlug.DataType._Int, data.CityId));
            param.Add(Connection.GetParameter("pCity", DataPlug.DataType._Varchar, data.City));
            param.Add(Connection.GetParameter("pState", DataPlug.DataType._Int, data.State));
            param.Add(Connection.GetParameter("pCountry", DataPlug.DataType._Int, data.CountryId));
            param.Add(Connection.GetParameter("pZipCode", DataPlug.DataType._Varchar, data.ZipCode));
            param.Add(Connection.GetParameter("pPhone", DataPlug.DataType._Varchar, data.Phone));
            param.Add(Connection.GetParameter("pMobile", DataPlug.DataType._Varchar, data.Mobile));
            param.Add(Connection.GetParameter("pType", DataPlug.DataType._Int, data.AddressType));
            object result = Connection.ExecuteQueryScalar("addressbilling_Save", param);

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

            CLayer.Address      byAddress = BLayer.Address.GetAddressOnUserId(UserId);
            CLayer.Address      adrs      = BLayer.Address.GetPrimaryOnUser(UserId);
            OfflinePaymentModel model     = new OfflinePaymentModel();

            if (byAddress != null && adrs != null)
            {
                model.Name      = byAddress.Firstname;
                model.Email     = byAddress.Email;
                model.Mobile    = adrs.Mobile;
                model.CityId    = adrs.CityId;
                model.City      = adrs.City;
                model.State     = adrs.State;
                model.CountryId = adrs.CountryId;
                model.ZipCode   = adrs.ZipCode;
                model.Address   = adrs.AddressText;
                if (model.State > 0)
                {
                    List <CLayer.City> cities = null;
                    cities = BLayer.City.GetOnState(model.State);
                    cities.Add(new CLayer.City()
                    {
                        CityId = -1, Name = "Other"
                    });
                    model.CityList = new SelectList(cities, "CityId", "Name");
                }
                model.LoadPlaces();

                return(View(model));
            }
            else
            {
                return(View(model));
            }
        }
Esempio n. 14
0
        public CLayer.Address GetAddressOnUserId(long UserId)
        {
            CLayer.Address            address = null;
            List <DataPlug.Parameter> param   = new List <DataPlug.Parameter>();

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

            if (dt.Rows.Count > 0)
            {
                address             = new CLayer.Address();
                address.Firstname   = Connection.ToString(dt.Rows[0]["Firstname"]);
                address.Lastname    = Connection.ToString(dt.Rows[0]["LastName"]);
                address.Email       = Connection.ToString(dt.Rows[0]["Email"]);
                address.City        = Connection.ToString(dt.Rows[0]["City"]);
                address.AddressText = Connection.ToString(dt.Rows[0]["Address"]);
                address.Country     = Connection.ToString(dt.Rows[0]["Country"]);
                address.Phone       = Connection.ToString(dt.Rows[0]["Phone"]);
                address.Mobile      = Connection.ToString(dt.Rows[0]["Mobile"]);
                address.StateName   = Connection.ToString(dt.Rows[0]["State"]);
                address.ZipCode     = Connection.ToString(dt.Rows[0]["ZipCode"]);
            }
            return(address);
        }
        //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);
        }
        public ActionResult CorporateDetails(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
                };
            }
            CLayer.B2B b2b = BLayer.B2B.Get(id);
            if (b2b != null)
            {
                details.MaxStaff      = b2b.MaximumStaff;
                details.Name          = b2b.Name;
                details.RequestStatus = b2b.RequestStatus;
            }
            //if (id > 0)
            //{
            //    ViewData["B2BId"] = id;
            //}
            if (b2b.RequestStatus == (int)CLayer.ObjectStatus.StatusType.NotVerified ||
                b2b.RequestStatus == (int)CLayer.ObjectStatus.StatusType.Unread)
            {
                BLayer.B2B.SetStatus(id, (int)CLayer.ObjectStatus.StatusType.Read);
            }
            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(details));
        }
        public ActionResult AffiliateDetails(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
                };
            }
            //if (id > 0)
            //{
            //    ViewData["B2BId"] = id;
            //}
            CLayer.B2B b2b = BLayer.B2B.Get(id.Value);
            if (b2b != null)
            {
                details.MaxStaff            = b2b.MaximumStaff;
                details.Name                = b2b.Name;
                details.PANNo               = b2b.PANNo;
                details.RequestStatus       = b2b.RequestStatus;
                details.PropertyDescription = b2b.PropertyDescription;
                details.AvailableProperties = b2b.AvailableProperties;
            }

            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;

                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();
            }

            List <CLayer.B2B> SupplierList = new List <CLayer.B2B>();

            SupplierList         = BLayer.B2B.GetAllSupplier(id.Value);
            details.SupplierList = SupplierList;

            return(View(details));
        }
Esempio n. 18
0
 public static long Save(CLayer.Address data)
 {
     DataLayer.Address address = new DataLayer.Address();
     data.Validate();
     return(address.Save(data));
 }
        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));
        }
Esempio n. 20
0
        private void Save2(Models.SupplierB2BModel data)
        {
            string tempName = "";

            if (data.UserType != (int)CLayer.Role.Roles.Agent)
            {
                if (data.ContactName == null)
                {
                    tempName = data.Name.TrimStart();//Business Name
                }
                else
                {
                    tempName = data.ContactName.TrimStart();// Name
                }
            }
            else
            {
                tempName = data.ContactName.TrimStart();
            }


            string tFirstName = tempName;
            string tLastName  = "";

            if (data.UserType == (int)CLayer.Role.Roles.Supplier)
            {
                tFirstName = tempName;
                tLastName  = tempName;
            }
            else if (data.UserType == (int)CLayer.Role.Roles.Corporate)
            {
                tFirstName = tempName;
                tLastName  = tempName;
            }
            else if (data.UserType == (int)CLayer.Role.Roles.Agent)
            {
                tFirstName = tempName;
                tLastName  = tempName;
            }
            else
            {
                // tFirstName = data.ContactName.TrimStart();
                // tLastName = data.ContactName.TrimStart();
                //---
                int firstspace = tempName.IndexOf(' ');
                if (firstspace > 1)
                {
                    if (firstspace < data.ContactName.Length - 1)
                    {
                        tFirstName = tempName.Split(' ')[0].ToString();
                        tLastName  = tempName.Substring(firstspace + 1, tempName.Length - tFirstName.Length - 1);
                    }
                }
                //----
            }
            CLayer.User usr = new CLayer.User()
            {
                SalutationId = 1,

                FirstName  = tFirstName,
                LastName   = "",
                Email      = data.Email,
                UserTypeId = data.UserType,
                Status     = (int)CLayer.ObjectStatus.StatusType.NotVerified
            };
            long UsrId = BLayer.User.Save(usr);

            CLayer.B2B b2b = new CLayer.B2B()
            {
                B2BId           = UsrId,
                Name            = data.Name,//Business Name
                ServiceTaxRegNo = data.ServiceTaxRegNo,
                PANNo           = data.PANNo,
                VATRegNo        = data.VATRegNo
            };

            if (data.UserType == (int)CLayer.Role.Roles.Supplier)
            {
                b2b.PropertyDescription = data.PropertyDescription;
                b2b.AvailableProperties = data.AvailableProperties;
            }
            data.B2BId = BLayer.B2B.Save(b2b);

            CLayer.Address address = new CLayer.Address()
            {
                AddressId   = 0,
                UserId      = UsrId,
                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);

            #region Billing Address For Corporate have to be here before "save" line of the address object
            if (data.UserType == (int)CLayer.Role.Roles.Corporate)
            {
                if (data.BillingAddress != "")
                {
                    CLayer.Address billingaddress = new CLayer.Address()
                    {
                        AddressId   = 0,
                        UserId      = UsrId,
                        AddressText = data.BillingAddress,
                        CityId      = data.BillingCityId,
                        State       = data.BillingState,
                        CountryId   = data.BillingCountryId,
                        ZipCode     = "",
                        Phone       = "",
                        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);
                }
            }
            #endregion

            #region Bank Account details for Supplier
            if (data.UserType == (int)CLayer.Role.Roles.Supplier)
            {
                if (data.BankName != "")
                {
                    CLayer.BankAccount account = new CLayer.BankAccount()
                    {
                        BankAccountId = 0,
                        UserId        = UsrId,
                        AccountName   = data.Name,//Business name
                        AccountNumber = data.AccountNumber,
                        BankName      = data.BankName,
                        BranchAddress = data.BranchAddress,
                        RTGSNumber    = data.RTGSNumber,
                        MICRCode      = data.MICRCode
                    };
                    BLayer.BankAccount.Save(account);
                }
            }
            #endregion

            #region File Attatchments
            if (data.ServiceTaxReg != null)
            {
                CLayer.UserFiles servicetax = new CLayer.UserFiles()
                {
                    UserId   = UsrId,
                    FileId   = 0,
                    FileName = UsrId.ToString() + DateTime.Now.ToString("ddMMyyyyHHmmss") + System.IO.Path.GetFileName(data.ServiceTaxReg.FileName),
                    Document = (int)CLayer.UserFiles.Documents.ServiceTaxRegNo
                };
                BLayer.UserFiles.Save(servicetax);
                SaveDocument(data.ServiceTaxReg, UsrId, servicetax.FileName);
            }
            if (data.VATReg != null)
            {
                CLayer.UserFiles vat = new CLayer.UserFiles()
                {
                    UserId   = UsrId,
                    FileId   = 0,
                    FileName = UsrId.ToString() + DateTime.Now.ToString("ddMMyyyyHHmmss") + System.IO.Path.GetFileName(data.VATReg.FileName),
                    Document = (int)CLayer.UserFiles.Documents.VATRegNo
                };
                BLayer.UserFiles.Save(vat);
                SaveDocument(data.VATReg, UsrId, vat.FileName);
            }
            if (data.BusinessRegistrationCertificate != null)
            {
                CLayer.UserFiles brc = new CLayer.UserFiles()
                {
                    UserId   = UsrId,
                    FileId   = 0,
                    FileName = UsrId.ToString() + DateTime.Now.ToString("ddMMyyyyHHmmss") + System.IO.Path.GetFileName(data.BusinessRegistrationCertificate.FileName),
                    Document = (int)CLayer.UserFiles.Documents.BusinessRegistrationCertificate
                };
                BLayer.UserFiles.Save(brc);
                SaveDocument(data.BusinessRegistrationCertificate, UsrId, brc.FileName);
            }
            if (data.PANCard != null)
            {
                CLayer.UserFiles pan = new CLayer.UserFiles()
                {
                    UserId   = UsrId,
                    FileId   = 0,
                    FileName = UsrId.ToString() + DateTime.Now.ToString("ddMMyyyyHHmmss") + System.IO.Path.GetFileName(data.PANCard.FileName),
                    Document = (int)CLayer.UserFiles.Documents.PANCard
                };
                BLayer.UserFiles.Save(pan);
                SaveDocument(data.PANCard, UsrId, pan.FileName);
            }
            if (data.CopyOfCheque != null)
            {
                CLayer.UserFiles cc = new CLayer.UserFiles()
                {
                    UserId   = UsrId,
                    FileId   = 0,
                    FileName = UsrId.ToString() + DateTime.Now.ToString("ddMMyyyyHHmmss") + System.IO.Path.GetFileName(data.CopyOfCheque.FileName),
                    Document = (int)CLayer.UserFiles.Documents.CopyOfCheque
                };
                BLayer.UserFiles.Save(cc);
                SaveDocument(data.CopyOfCheque, UsrId, cc.FileName);
            }
            #endregion
        }
Esempio n. 21
0
        public async Task <ActionResult> Guest(Models.GuestModel data)
        {
            try
            {
                InitViewBag();
                if (ModelState.IsValid)
                {
                    long guestId = BLayer.User.CreateGuest(data.Email, data.Phone);
                    if (guestId > 0)
                    {
                        if (BLayer.User.GetStatus(guestId) == CLayer.ObjectStatus.StatusType.NotVerified)
                        {
                            string gd = Guid.NewGuid().ToString().Substring(0, 10);
                            UserManager <StayBazar.Lib.Security.IdentityUser> UserManager = new UserManager <StayBazar.Lib.Security.IdentityUser>(new UserStore());
                            string hashedNewPassword = UserManager.PasswordHasher.HashPassword(gd);
                            BLayer.User.SetPassword(guestId, hashedNewPassword);
                            try
                            {
                                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                                msg.To.Add(data.Email);
                                //Send guest mail
                                string url = System.Configuration.ConfigurationManager.AppSettings.Get("GuestMail");
                                url = url + guestId.ToString() + "&key=" + BLayer.Settings.GetValue(CLayer.Settings.PUBLIC_PAGE_LOCK) + "&pass="******"Staybazar Account";
                                msg.IsBodyHtml = true;
                                Common.Mailer ml = new Common.Mailer();
                                try
                                {
                                    await ml.SendMailAsync(msg, Common.Mailer.MailType.Query);
                                }
                                catch (Exception ex)
                                { //TODO add the exception to mailer list
                                    Common.LogHandler.LogError(ex);
                                }
                            }
                            catch (Exception ex) { Common.LogHandler.LogError(ex); }
                        }
                        Session[CLayer.ObjectStatus.GUEST_ID_SESSION] = guestId;
                        CLayer.Address ad = BLayer.Address.GetOnUserId(guestId, (int)CLayer.Address.AddressTypes.Primary);
                        if (ad == null)
                        {
                            return(RedirectToAction("SetAddress", "Continue"));
                        }
                        if (ad.CountryId < 1 && ad.State < 1)
                        {
                            return(RedirectToAction("SetAddress", "Continue"));
                        }
                        return(RedirectToAction("Book", "Booking"));
                    }
                    ViewBag.GuestError = true;
                    ViewBag.Message    = "Sorry we could not create a guest account. Try again later.";
                }
                else
                {
                    ViewBag.GuestError = true;
                    ViewBag.Message    = "Sorry we could not create a guest account. Try again.";
                }
            }catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                ViewBag.GuestError = true;
                ViewBag.Message    = "Could not create guest login. Technical failure.";
            }
            return(View("Index"));
        }
Esempio n. 22
0
        //RESEND EMAIL
        public async Task <bool> ResendemailC(long bookingId)
        {
            //send customer email/message
            //email
            if (bookingId < 1)
            {
                return(false);
            }
            CLayer.Address        byUser  = BLayer.Bookings.GetBookedByUser(bookingId);
            List <CLayer.Address> forUser = BLayer.Bookings.GetBookedForUser(bookingId);

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

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

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

                msg.IsBodyHtml = true;

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

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

                    msg.IsBodyHtml = true;
                    try
                    {
                        await ml.SendMailAsync(msg, Common.Mailer.MailType.Reservation);
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.HandleError(ex);
                    }
                }
                catch (Exception ex)
                {
                    Common.LogHandler.HandleError(ex);
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(true);
        }
        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));
        }
        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 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));
        }
Esempio n. 28
0
 public static long BillingAddress(CLayer.Address data)
 {
     DataLayer.Address address = new DataLayer.Address();
     data.Validate();
     return(address.BillingAddress(data));
 }
Esempio n. 29
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);
        }