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"));
     }
 }
Example #2
0
        public ActionResult TravelAgentSave(Models.B2BModel data)
        {
            try
            {
                if (data != null)
                {
                    data.LoadPlaces();
                }
                if (ModelState.IsValid)
                {
                    ViewBag.Message = null;
                    if (BLayer.User.GetUserIdbystatus(data.Email) > 0)
                    {
                        ViewBag.Message = "The email id already used by someone else";
                        return(View("TravelAgent", data));
                    }
                    else
                    {
                        int    maxContentLength = 1024 * 1024;// 1 MB  //*3; //3 MB
                        string extensions       = ConfigurationManager.AppSettings.Get("DocumentFileTypes");
                        int    maxFileSize      = Convert.ToInt32(ConfigurationManager.AppSettings.Get("FileSizeInMB"));
                        maxContentLength = maxContentLength * maxFileSize;
                        //string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".pdf", ".doc", ".xlsx", ".docx", ".xls" };
                        string[] allowedFileExtensions = extensions.Split(',');

                        if (data.ServiceTaxReg != null && data.BusinessRegistrationCertificate != null &&
                            data.PANCard != null && data.CopyOfCheque != null &&
                            data.ServiceTaxReg.ContentLength > 0 && data.BusinessRegistrationCertificate.ContentLength > 0 &&
                            data.PANCard.ContentLength > 0 && data.CopyOfCheque.ContentLength > 0)
                        {
                            if (!allowedFileExtensions.Contains(data.ServiceTaxReg.FileName.Substring(data.ServiceTaxReg.FileName.LastIndexOf('.'))) ||
                                !allowedFileExtensions.Contains(data.BusinessRegistrationCertificate.FileName.Substring(data.BusinessRegistrationCertificate.FileName.LastIndexOf('.'))) ||
                                !allowedFileExtensions.Contains(data.PANCard.FileName.Substring(data.PANCard.FileName.LastIndexOf('.'))) ||
                                !allowedFileExtensions.Contains(data.CopyOfCheque.FileName.Substring(data.CopyOfCheque.FileName.LastIndexOf('.'))))
                            {
                                ViewBag.Message = "Invalid document type. Please use these file types: " + string.Join(", ", allowedFileExtensions);
                                return(View("TravelAgent", data));
                            }
                            else if (data.ServiceTaxReg.ContentLength > maxContentLength ||
                                     data.BusinessRegistrationCertificate.ContentLength > maxContentLength ||
                                     data.PANCard.ContentLength > maxContentLength ||
                                     data.CopyOfCheque.ContentLength > maxContentLength)
                            {
                                ViewBag.Message = "Your file is too large, maximum allowed size is: 1 MB";
                                return(View("TravelAgent", data));
                            }
                            else
                            {
                                data.UserType = (int)CLayer.Role.Roles.Agent;
                                Save(data);
                                Response.Redirect("/Join/TravelAgent/Thank-You", true);
                                return(View());
                            }
                        }
                        else
                        {
                            ViewBag.Message = "The documents are not selected";
                            return(View("TravelAgent", data));
                        }
                    }
                }
                else
                {
                    ViewBag.Message = "Please fill all the required fields";
                    return(View("TravelAgent", data));
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/ErrorPage"));
            }
        }
Example #3
0
        public ActionResult Index()
        {
            Models.B2BModel m = new Models.B2BModel();

            return(View());
        }
Example #4
0
        private void Save(Models.B2BModel 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,
                ContactDesignation = data.ContactDesignation
            };

            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.Normal
            };

            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.Normal;
            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.IsClicked == true)
                {
                    CLayer.Address billingaddress = 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 != "")
                    {
                        billingaddress.City = data.City;
                    }
                    if (data.CityId > 0)
                    {
                        billingaddress.City = BLayer.City.Get(data.CityId).Name;
                    }
                    BLayer.Address.Save(billingaddress);
                }
                else
                {
                    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     = data.BillingZipCode,
                            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);
                    }
                    //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.Normal
                    //    };
                    //    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.CorporateLogo != null)
            {
                CLayer.UserFiles corporatelogo = new CLayer.UserFiles()
                {
                    UserId   = UsrId,
                    FileId   = 0,
                    FileName = UsrId.ToString() + DateTime.Now.ToString("ddMMyyyyHHmmss") + System.IO.Path.GetFileName(data.CorporateLogo.FileName),
                    Document = (int)CLayer.UserFiles.Documents.CorporateLogo
                };
                BLayer.UserFiles.Save(corporatelogo);
                SaveDocument(data.CorporateLogo, UsrId, corporatelogo.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
        }