Beispiel #1
0
        public ActionResult ContactUs(SessionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var to = model.ContactUsModel.Email;
                var subject = "Bank Performance Index Contact Us";
                var body = "Dear " + model.ContactUsModel.FullName + " \r\n\r\n"
                    + "Thank you for your inquiry. Online business inquiries are managed by Icovian team members in our corporate headquarters during regular business hours (Monday - Friday / 8 AM - 5 PM EST). We will make every effort to respond to you within one business day. \r\n\r\n"
                    + "Regards \r\n"
                    + "Client Services";
                Email.SendMail(to, subject, body);

                to = "*****@*****.**";
                body = "Name: " + model.ContactUsModel.FullName + "\r\n\r\n"
                    + "Title: " + model.ContactUsModel.Title + "\r\n\r\n"
                    + "Company: " + model.ContactUsModel.Company + "\r\n\r\n"
                    + "Email: " + model.ContactUsModel.Email + "\r\n\r\n"
                    + "Phone Number: " + model.ContactUsModel.PhoneNumber + "\r\n\r\n"
                    + "Reason: " + model.ContactUsModel.Reason + "\r\n"
                    + "Message: " + model.ContactUsModel.Message;
                Email.SendMail(to, subject, body);

                return View("ContactConfirm", model);
            }
            return View("Contact", model);
        }
        public ActionResult Login(SessionViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var user = SubscriberModel.ValidateSubscriber(model.LoginViewModel.UserName, model.LoginViewModel.Password);
                if (user != null)
                {

                    SessionViewModel sessionModel = new SessionViewModel();
                    sessionModel.CurrentFilters = new Dictionary<string, string>();

                    //  TODO: MAKE SURE THERE IS SOMETHING HERE WHEN GOING TO A CONSULTANT
                    string currentInstitution = "";
                    if(user.CompanyType == 1){
                        currentInstitution = SubscriberModel.GetUserCompany(user.SubscriberId).CompanyName;
                    }

                    sessionModel.CurrentFilters.Add(Constants.CURRENT_INSTITUTION_FDIC, currentInstitution);
                    sessionModel.SubscriberViewModel = user;

                    Session[Constants.SESSION_NAME] = sessionModel;

                    #region FA cookie
                    var serializeModel = new BlipShipPrincipalSerializeModel
                    {
                        UserId = 1,
                        UserName = model.LoginViewModel.UserName,
                    };

                    string userData = JsonConvert.SerializeObject(serializeModel);
                    var ticket = new FormsAuthenticationTicket(
                        1,
                        "bpicookie",
                        DateTime.Now,
                        DateTime.Now.AddMinutes(120),
                        false,
                        userData,
                        FormsAuthentication.FormsCookiePath
                        );

                    string encryptedTicket = FormsAuthentication.Encrypt(ticket);
                    var formsCookie = new HttpCookie("bpicookie", encryptedTicket);

                    Response.Cookies.Add(formsCookie);
                    #endregion

                    return RedirectToAction("Index", "Dashboard");
                }
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }
        public ActionResult Index(SessionViewModel model)
        {
            if (Session[Constants.SESSION_NAME] == null)
            {
                Session[Constants.SESSION_NAME] = new SessionViewModel();
            }

            var sessionModel = Session[Constants.SESSION_NAME] as SessionViewModel;

            //  MAKES SURE IF BANK IS SELECTED THERE IS AN FDIC NUMBER
            if (model.SubscriberViewModel.CompanyType == 1 && string.IsNullOrEmpty(model.SubscriberViewModel.FdicCertNumber))
            {
                ModelState.AddModelError("RegisterViewModel.FdicCertNumber", "The FDIC Certificate Number field is required.");
            }

            //  MAKES SURE THE FDIC NUMBER IS VALID
            if (model.SubscriberViewModel.CompanyType == 1 && !SubscriberModel.IsValidFdicNumber(model.SubscriberViewModel.FdicCertNumber))
            {
                ModelState.AddModelError("RegisterViewModel.FdicCertNumber", "The FDIC Certificate Number is not associated with an institution.");
            }

            //  MAKES SURE IF OTHER IS SELECTED THERE IS A COMPANY NAME
            if (model.SubscriberViewModel.CompanyType == 3 && string.IsNullOrEmpty(model.SubscriberViewModel.CompanyName))
            {
                ModelState.AddModelError("RegisterViewModel.FdicCertNumber", "The Company Name field is required.");
            }

            if (ModelState.IsValid) {
                //  USING THE SUBSCRIBER VIEW MODEL WE CREATE SUBSCRIPTION INFO

                model.SubscriberViewModel.SubscriptionTerms = Request["subscriptionTerms"].ToString();

                var subscriber = new SubscriberModel().AddSubscriber(
                    model.SubscriberViewModel.FdicCertNumber,
                    model.SubscriberViewModel.FirstName,
                    model.SubscriberViewModel.LastName,
                    model.SubscriberViewModel.CompanyType,
                    model.SubscriberViewModel.UserName,
                    model.SubscriberViewModel.Password,
                    model.SubscriberViewModel.CompanyName,
                    model.SubscriberViewModel.CardHolderName,
                    model.SubscriberViewModel.CardHolderZip,
                    model.SubscriberViewModel.CreditCardNumber,
                    model.SubscriberViewModel.Cvv,
                    model.SubscriberViewModel.ExpirationMonth,
                    model.SubscriberViewModel.ExpirationYear,
                    model.SubscriberViewModel.SubscriptionTerms);

                sessionModel.SubscriberViewModel = subscriber;

                sessionModel.CurrentFilters = new Dictionary<string, string>();
                //  TODO: GET THE FDIC NUMBER OR LAST SELECTED
                sessionModel.CurrentFilters.Add(Constants.CURRENT_INSTITUTION_FDIC, subscriber.CompanyName);

                #region FA cookie
                var serializeModel = new BlipShipPrincipalSerializeModel
                {
                    UserId = 1,
                    UserName = model.LoginViewModel.UserName,
                };

                string userData = JsonConvert.SerializeObject(serializeModel);
                var ticket = new FormsAuthenticationTicket(
                    1,
                    FormsAuthentication.FormsCookieName,
                    DateTime.Now,
                    DateTime.Now.AddMinutes(120),
                    false,
                    userData,
                    FormsAuthentication.FormsCookiePath
                    );

                string encryptedTicket = FormsAuthentication.Encrypt(ticket);
                var formsCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

                Response.Cookies.Add(formsCookie);
                #endregion

                Session[Constants.SESSION_NAME] = sessionModel;
                return RedirectToAction("Index", "Dashboard");
            }

            sessionModel.SubscriberViewModel = model.SubscriberViewModel;
            sessionModel.SubscriberViewModel.SubscriptionList = SubscriberModel.GetSubscriptionList();
            Session[Constants.SESSION_NAME] = sessionModel;
            return View(sessionModel);
        }
        public ActionResult ExportChart(string svg, SessionViewModel.ExportFormat format)
        {
            //INKSCAPE_PATH = Path.Combine(Server.MapPath("/InkscapePortable/"), "InkscapePortable.exe");

            var svgText = HttpUtility.UrlDecode(svg);
            var svgFile = TempFileName() + ".svg";
            System.IO.File.WriteAllText(svgFile, svgText);

            var fmt = format == SessionViewModel.ExportFormat.PDF ? "pdf" : "png";

            var api = new CloudConvert("sA6hlyZSnuhnK8miBRAz86Z4LM_w4By1gTdzR2rgmd8_2lQLrqIRdwyU6u_9901zV68Du37iTf5cC5_jsMBOCA");
            var processUrl = api.GetProcessURL("svg", fmt);
            var outFile = api.UploadFile(processUrl, svgFile, fmt);

            var jObject = JObject.Parse(outFile);
            var jToken = jObject["output"];
            var returlUrl = "https://" + jToken["url"].ToString();

            return Redirect(returlUrl);
        }