public ActionResult Registration(SchoolRegistration values) { Register register = new Register(); var registerdvalue = register.SchoolvisitorInformation(values); return(Json("Success")); }
public IActionResult Edit(SchoolRegistration entity) { MongoDBContext dbContext = new MongoDBContext(); //you can use the UpdateOne to get higher performance if you need. dbContext.SchoolRegistrations.ReplaceOne(m => m.Id == entity.Id, entity); return(View(entity)); }
public IActionResult Add(SchoolRegistration entity) { MongoDBContext dbContext = new MongoDBContext(); entity.Id = Guid.NewGuid(); dbContext.SchoolRegistrations.InsertOne(entity); return(Redirect("/SchoolRegistration")); }
public IHttpActionResult PostSchoolRegistration(SchoolRegistration schoolRegistration) { try { //ILandingPageSurvey surveyService = new LandingPageSurvey(); //surveyService.CreateQuestions(surveyQuestionList); return(Json(new Response { Message = "Question created successfuly", Status = true, Data = null })); } catch (Exception e) { throw e; } }
public Response SchoolvisitorInformation(SchoolRegistration slkReg) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri("http://localhost:64344/api/LandingPage/PostSchoolRegistration")); var postData = slkReg; JavaScriptSerializer s = new JavaScriptSerializer(); var data = s.Serialize(postData); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = data.Length; using (var streamWriter = new StreamWriter(request.GetRequestStream())) { streamWriter.Write(data); streamWriter.Flush(); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); return(new Response { Message = "Posted data to Web API", Data = responseString, Status = true }); } catch (Exception) { return(new Response { Message = "Cannot connect to Web API", Data = null, Status = false }); } }