public ActionResult Distributeri() { log.Info($"Browser: {Request.Browser.Browser}, Version: {Request.Browser.Version}, UserAgent: {Request.UserAgent}"); DistributerVM distVM = new DistributerVM(); return(View(distVM)); }
public JsonResult SaveFormData(DistributerVM distributerVM) { //Validate Google recaptcha here var response = Request["g-recaptcha-response"]; string secretKey = ConfigurationManager.AppSettings["GoogleReCaptchaSecretKey"]; var client = new WebClient(); var result = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, response)); var obj = JObject.Parse(result); var status = (bool)obj.SelectToken("success"); if ((!ModelState.IsValid) || !status) { if (!status) { ModelState.AddModelError("GoogleReCaptcha greška", "Google reCaptcha validacija nije uspjela"); } return(Json(new { status = false, errors = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage).ToList() }, JsonRequestBehavior.AllowGet)); } else { Session["Distributer"] = distributerVM; var uploadPath = System.Configuration.ConfigurationManager.AppSettings["OnLinePrijaveUploadFolder"]; var folderName = distributerVM.VrijemePrijave + "_" + distributerVM.Ime + "_" + distributerVM.Prezime + '_' + distributerVM.SifraKandidata + "_" + "Distributeri"; var fullUploadPath = uploadPath + folderName; bool exists = System.IO.Directory.Exists(fullUploadPath); if (!exists) { System.IO.Directory.CreateDirectory(fullUploadPath); } Session["FullUploadPath"] = fullUploadPath; return(Json(new { status = true })); } }