Esempio n. 1
0
        public ActionResult Login(Admin admin)
        {
            string encryptedPassword = BrokerUtility.EncryptURL(admin.Password);
            //DataSet dsUsers= BrokerWebDB.BrokerWebDB.validateAdminGetUsers(admin.Username, encryptedPassword);
            List <UserList> userList = new List <UserList>();

            userList = BrokerWebDB.BrokerWebDB.validateAdminGetUsers(admin.Username, encryptedPassword);
            User adminInfo = BrokerWebDB.BrokerWebDB.getAdminInfo(admin.Username, encryptedPassword);

            if (userList != null)
            {
                if (userList.Count > 0)
                {
                    Session["searchBy"]      = "-1";
                    Session["UsersList"]     = userList;
                    Session["Error"]         = "False";
                    Session["AdminId"]       = adminInfo.UserId;
                    Session["AdminUserName"] = adminInfo.EmailId;
                    CreateLoginIdentity(adminInfo.EmailId, adminInfo.UserId);
                    return(RedirectToAction("AdminHomePage", "Admin"));
                }
                else
                {
                    ViewBag.error = "Invalid username and password";
                }
            }
            else
            {
                ViewBag.error = "Invalid username and password";
            }

            return(View());
        }
Esempio n. 2
0
        public ActionResult ResetPassword(ResetPassword Info)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string Password = "", TempPass = "";

                    if (Info.Password != "" && Info.Password != null)
                    {
                        Password = Info.Password.ToString();

                        TempPass = BrokerUtility.EncryptURL(Password);

                        int Flag = BrokerUtility.ResetPassWord(Session["EmailId"].ToString(), TempPass);
                        if (Flag > 0)
                        {
                            int    Flag1    = BrokerWSUtility.ForgetPasswordRanNum(Session["EmailId"].ToString(), "");
                            string UserType = Session["ResetPasswordUserType"].ToString();

                            if (UserType == "Customer")
                            {
                                ViewBag.LoginUrl = "CustomerLogin";
                            }
                            else if (UserType == "Broker")
                            {
                                ViewBag.LoginUrl = "BrokerLogin";
                            }

                            ViewBag.Message = "Your password has been reset successfully.";

                            return(View("ResetResult"));
                        }
                        else
                        {
                            ViewBag.Message = "Password could not reset. Please try again. ";
                            return(View("ResetResult"));
                        }
                    }
                    else
                    {
                        return(View());
                    }
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception Ex)
            {
                ViewBag.Message = "Password could not reset. Please try again. ";
                return(View("ResetResult"));
            }
        }
Esempio n. 3
0
        public ActionResult VerifyEmail(ResetPassword Info)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string Password = "", TempPass = "";

                    if (Info.Password != "" && Info.Password != null)
                    {
                        Password = Info.Password.ToString();

                        TempPass = BrokerUtility.EncryptURL(Password);

                        int Flag = BrokerWSUtility.CreateNewPassword(Session["DecryptedEmailId"].ToString(), TempPass);
                        if (Flag > 0)
                        {
                            ViewData["EmailVerifyMessage"] = strEmailVerifyMessage;

                            ViewData["LoginUrl"] = "CustomerLogin";
                            return(View("VerifyEmailSuccess"));
                        }
                        else
                        {
                            ViewData["EmailVerifyMessage"] = "Email verification link is expired. Please try again";
                            ViewData["Login"] = "";
                            return(View("VerifyEmailFail"));
                        }
                    }
                    else
                    {
                        return(View());
                    }
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception Ex)
            {
                ViewData["EmailVerifyMessage"] = "Email Verification Failed. Please try again";
                ViewData["Login"] = "";
                return(View("VerifyEmailFail"));
            }

            //return View("Index");
        }
Esempio n. 4
0
        public JsonResult EncryptBrokerData(string BrokerMessageId, string CustomerMessageId, string BrokerId, string CustomerId, string CustomerName)
        {
            string this_BrokerMessageId   = BrokerMessageId;
            string this_CustomerMessageId = CustomerMessageId;
            string this_BrokerId          = BrokerId;
            string this_CustomerId        = CustomerId;
            string this_CustomerName      = CustomerName;

            this_BrokerMessageId   = BrokerUtility.EncryptURL(this_BrokerMessageId);
            this_CustomerMessageId = BrokerUtility.EncryptURL(this_CustomerMessageId);
            this_BrokerId          = BrokerUtility.EncryptURL(this_BrokerId);
            this_CustomerId        = BrokerUtility.EncryptURL(this_CustomerId);
            this_CustomerName      = BrokerUtility.EncryptURL(this_CustomerName);


            return(Json(new { BrokerMessageId = this_BrokerMessageId, CustomerMessageId = this_CustomerMessageId, BrokerId = this_BrokerId, CustomerId = this_CustomerId, CustomerName = this_CustomerName }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public ActionResult UpdateProfileView(UpdateModel data, FormCollection val)
        {
            int user;

            try
            {
                if (ModelState.IsValid)
                {
                    string encryptedPassword = BrokerUtility.EncryptURL(data.Password);
                    int?   state             = data.StateId;
                    int?   country           = data.CountryId;
                    user = BrokerUtility.UpdateUser(Session["UserId"].ToString(), encryptedPassword, data.Address, data.City, state, country, data.PinCode, data.MobNo, "1", data.UserType, "1");
                    if (user > 0)
                    {
                        CreateLoginIdentity(data.FirstName + ' ' + data.LastName, Convert.ToInt32(Session["UserId"].ToString()));
                        return(RedirectToAction("Index", "Home"));
                    }

                    else
                    {
                        ViewBag.UserExist = "Error occured while updating your profile.";
                    }
                }
                else
                {
                    ViewBag.validateerror = "Please validate all input";
                }
            }
            catch (Exception ex)
            {
                BrokerUtility.ErrorLog(Convert.ToInt32(Session["UserId"].ToString()), "UpdateProfileView", ex.Message.ToString(), "HomeController.cs_UpdateProfileView()", BrokerUtility.GetIPAddress(Session["UserId"].ToString()));
            }
            return(View(data));

            //return View(model);
        }
        public ActionResult APSPCustomerSignUp(MeinekeCustomerSignUp Cust, IEnumerable <HttpPostedFileBase> file)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string FirstName = "", LastName = "", Email = "", Phone1 = "", Phone2 = "", Phone3 = "", Password = "",
                           TempPass = "", ZipCode = "", ProfilePhoto = "", HouseType = "", Address = "", IsCars = "",
                           Occupation = "", CompanyName = "", Phone = "", FieldName1 = "", RenamedImageName = "", FileName2 = "", NoofEmployee = "", EstPremium = "", Website = "";
                    int NoOfCars = 0, UserId = 0;

                    List <uspSaveCustomerBasicDetails_Result> User1 = null;
                    //UserId = Convert.ToInt32(Session["UserId"].ToString());

                    if (Cust.FirstName != null)
                    {
                        FirstName = Cust.FirstName.ToString();
                    }
                    if (Cust.LastName != null)
                    {
                        LastName = Cust.LastName.ToString();
                    }
                    if (Cust.CompanyName != null)
                    {
                        CompanyName = Cust.CompanyName.ToString();
                    }
                    if (Cust.Address != null)
                    {
                        Address = Cust.Address.ToString();
                    }
                    if (Cust.EmailId != null)
                    {
                        Email = Cust.EmailId.ToString();
                    }
                    if (Cust.PhoneNo != null)
                    {
                        Phone = Cust.PhoneNo.ToString();
                    }
                    if (Cust.Website != null)
                    {
                        Website = Cust.Website.ToString();
                    }
                    if (Cust.ZipCode != null)
                    {
                        ZipCode = Cust.ZipCode.ToString();
                    }
                    if (Cust.NoofEmployees != null)
                    {
                        NoofEmployee = Cust.NoofEmployees.ToString();
                    }
                    if (Cust.EstPremium != null)
                    {
                        EstPremium = Cust.EstPremium.ToString();
                    }

                    string random        = BrokerWSUtility.GetRandomNumber();
                    string Encryptrandom = BrokerUtility.EncryptURL(random);
                    Session["random"] = Encryptrandom;

                    User1 = BrokerUtility.SaveCustomerBasicDetails(FirstName, LastName, Phone, Email, Address, ZipCode, TempPass, Encryptrandom, HouseType, IsCars, NoOfCars, Occupation, CompanyName, NoofEmployee, EstPremium, Website, "APSP");
                    int Flag = 0;

                    if (User1.Count > 0)
                    {
                        UserId             = Convert.ToInt32(User1[0].UserId.ToString());
                        Session["UserId"]  = UserId;
                        Session["EmailId"] = User1[0].EmailId.ToString();

                        //////////////////// Access Profile Pic and Resume Files //////////////////////////
                        if (file == null)
                        {
                        }
                        else
                        {
                            foreach (var f in file)
                            {
                                if (f != null)
                                {
                                    if (f.ContentLength > 0)
                                    {
                                        int      MaxContentLength      = 1024 * 1024 * 4; //Size = 4 MB
                                        string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".pdf", ".jpe", ".jpeg" };
                                        if (!AllowedFileExtensions.Contains
                                                (f.FileName.Substring(f.FileName.LastIndexOf('.')).ToLower()))
                                        {
                                            ModelState.AddModelError("File", "Please file of type: " + string.Join(", ", AllowedFileExtensions));
                                        }
                                        else if (f.ContentLength > MaxContentLength)
                                        {
                                            ModelState.AddModelError("File", "Your file is too large, maximum allowed size is: " + MaxContentLength + " MB");
                                        }
                                        else
                                        {
                                            var fileName = Path.GetFileName(f.FileName);
                                            //var Name = Path.GetFileNameWithoutExtension(f.FileName);
                                            var path = Path.Combine(Server.MapPath("~/UploadedDoc"), fileName);
                                            //Save file on server.
                                            //f.SaveAs(path);

                                            //Convert input file to Base 64 string

                                            byte[] binaryData;
                                            binaryData = new Byte[f.InputStream.Length];
                                            long bytesRead = f.InputStream.Read(binaryData, 0, (int)f.InputStream.Length);
                                            f.InputStream.Close();
                                            string base64String = System.Convert.ToBase64String(binaryData, 0, binaryData.Length);

                                            string FileName1 = "";
                                            //  string FileName2 = "";
                                            string FieldName = "";

                                            string ProfilePic = Cust.ProfilePicture.ToString().Replace("C:\\fakepath\\", "");

                                            if (ProfilePic == fileName)
                                            {
                                                FileName1 = System.Web.HttpContext.Current.Server.MapPath("~/ProfilePicture/" + Cust.EmailId.ToString() + "_" + UserId + ".txt");
                                                FieldName = "ProfilePicture";
                                                FileName2 = Cust.EmailId.ToString() + "_" + UserId + ".txt";

                                                //Save Image on Server also.

                                                // Convert byte[] to Image

                                                byte[]       imageBytes1 = Convert.FromBase64String(base64String);
                                                MemoryStream ms1         = new MemoryStream(imageBytes1, 0, imageBytes1.Length);

                                                ms1.Write(imageBytes1, 0, imageBytes1.Length);
                                                System.Drawing.Image image1 = System.Drawing.Image.FromStream(ms1, true);

                                                //image1.Save(System.Web.HttpContext.Current.Server.MapPath("~/UploadedImages/ProfilePicture/" + Email + "_" + UserId + ".png"), System.Drawing.Imaging.ImageFormat.Png);

                                                System.Drawing.Image thumbnail = image1.GetThumbnailImage(200, 200, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
                                                thumbnail.Save(System.Web.HttpContext.Current.Server.MapPath("~/UploadedImages/ProfilePicture/" + Email + "_" + UserId + ".png"), System.Drawing.Imaging.ImageFormat.Png);

                                                FieldName1       = "ProfilePictureImg";
                                                RenamedImageName = Cust.EmailId.ToString() + "_" + UserId + ".png";
                                            }

                                            //Check for the file already exist or not
                                            bool CheckFile = BrokerUtility.CheckFile(FileName1);
                                            if (CheckFile)
                                            {
                                                //Create a text file of Base 64 string
                                                bool result = BrokerUtility.WriteFile(FileName1, base64String);

                                                if (result)
                                                {
                                                    Flag = BrokerUtility.SaveBrokerFiles(FileName2, UserId, FieldName, FieldName1, RenamedImageName);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        // Send Verification Link on Email Id

                        //string random = BrokerWSUtility.GetRandomNumber();

                        bool EmailFlag = false;

                        EmailFlag = BrokerWSUtility.SendRegistrationEmailFromWebSite(Session["EmailId"].ToString(), Session["random"].ToString(), Session["UserId"].ToString(), "Customer");
                        //EmailFlag = true;
                        if (EmailFlag)
                        {
                            ViewBag.VerificationMessage  = "You are registered successfully but yet not activated. ";
                            ViewBag.VerificationMessage1 = "Please accept your verification email.";
                            ViewBag.Company = "APSP";
                            return(View("CustomerSuccess"));
                        }
                        else
                        {
                            //If User registerd successfully, but verification link has not
                            //been sent over EmailId
                            //ViewBag.VerificationMessage = "You are registered successfully but yet not activated. <br/>Please accept your verification email.";
                            ViewBag.Company = "APSP";
                            return(View("CustomerError"));
                        }
                    }
                }
                catch (Exception Ex)
                {
                    BrokerUtility.ErrorLog(Convert.ToInt32(Session["UserId"].ToString()), "Index_POST_Wesite", Ex.Message.ToString(), "CustomerRegistrationController.cs_Index_POST", BrokerUtility.GetIPAddress(Session["UserId"].ToString()));
                    return(View());
                }
                return(View());
            }
            return(View());
        }