public int SudentInsert(usp_StudentbyIDGet_Result studentDetails) { int result = playschool.usp_StudentInsert(studentDetails.StudentName, studentDetails.GenderId, studentDetails.DOB, studentDetails.DOJ, studentDetails.FatherName, studentDetails.FatherOccupationId, studentDetails.FatherMobileNumber, studentDetails.MotherName, studentDetails.MotherOccupationId, studentDetails.MotherMobileNumber, studentDetails.Address1, studentDetails.Address2, studentDetails.CityID, studentDetails.StudentPhoto, studentDetails.FatherPhoto, studentDetails.MotherPhoto, studentDetails.EmailId, studentDetails.Timings, studentDetails.fees, studentDetails.StudentSourceId, studentDetails.AdmissionRemarks, studentDetails.UserID); return(result); }
public ActionResult GetAddress(usp_StudentbyIDGet_Result student) { // List <usp_CountryGet_Result> CountryList = new List <usp_CountryGet_Result>(); List <SelectListItem> CountryListItem = new List <SelectListItem>(); AddressModel address = new AddressModel(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseUrl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource GetAllEmployees using HttpClient HttpResponseMessage Res = client.GetAsync("Comman/GetCountries").Result; if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var EmpResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Employee list CountryList = JsonConvert.DeserializeObject <List <usp_CountryGet_Result> >(EmpResponse); } CountryList.ForEach(x => { CountryListItem.Add(new SelectListItem { Text = x.CountryName, Value = x.CountryID.ToString() }); }); ViewBag.CountryName = CountryListItem; //address.CountryName = student.CountryName; address.CountryID = student.CountryID; address.StateId = student.StateID; address.Address1 = student.Address1; address.Address2 = student.Address2; address.Zipcode = student.ZipCode; //List<SelectListItem>(.ToString()) ; ViewBag.StateName = getState(student.CountryID); //List<SelectListItem> State = JsonConvert.DeserializeObject<List<SelectListItem>>(result); ; // return Json(CountryList, JsonRequestBehavior.AllowGet); return(PartialView("~/Views/Shared/_AddressPartialStrongly.cshtml", address)); // return View(address); } }
public async Task <ActionResult> EditStudent(int?id) { if (Session["LoginInfo"] != null) { //if (id != null) //{ List <usp_StudentbyIDGet_Result> studentList = new List <usp_StudentbyIDGet_Result>(); usp_StudentbyIDGet_Result studentDetail = new usp_StudentbyIDGet_Result(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseUrl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync("Student/GetStudentByID?id=" + id.ToString()); response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) { var studentresponse = response.Content.ReadAsStringAsync().Result; studentList = JsonConvert.DeserializeObject <List <usp_StudentbyIDGet_Result> >(studentresponse); studentDetail = studentList.Find(student => student.StudentID == id); } } } catch (Exception ex) { } return(View(studentDetail)); // } } else { return(RedirectToAction("Index", "UserLogin", new { area = "Login" })); } }
public async Task <ActionResult> CreateStudent(usp_StudentbyIDGet_Result student) { try { if (Session["LoginInfo"] != null) { if (ModelState.IsValid) { // usp_StudentbyIDGet_Result studentdetails = new usp_StudentbyIDGet_Result(); string studentphoto = string.Empty, fatherphoto = string.Empty, motherphoto = string.Empty; //studentdetails.StudentName = student.StudentName.ToString(); student.StateID = Convert.ToInt32(Request.Form["State"].ToString()); student.CountryID = Convert.ToInt32(Request.Form["CountryName"].ToString()); student.CityID = Convert.ToInt32(Request.Form["City"].ToString()); student.GenderId = Convert.ToInt32(Request.Form["Gender"].ToString()); student.MotherOccupationId = Convert.ToInt32(Request.Form["MotherOccupation"].ToString()); student.FatherOccupationId = Convert.ToInt32(Request.Form["City"].ToString()); student.StudentSourceId = Convert.ToInt32(Request.Form["StudentSource"].ToString()); var fp = Request.Files["studentphoto"]; if (fp != null && fp.ContentLength >= 0) { var fileName = Path.GetFileName(fp.FileName); Guid Id = Guid.NewGuid(); studentphoto = "~/App_Data/Upload/" + Id.ToString() + Path.GetExtension(fileName); string path = Server.MapPath("~/App_Data/Upload/") + Id.ToString() + Path.GetExtension(fileName); fp.SaveAs(path); fp = null; } fp = Request.Files["fatherphoto"]; if (fp != null && fp.ContentLength >= 0) { var fileName = Path.GetFileName(fp.FileName); Guid Id = Guid.NewGuid(); fatherphoto = "~/App_Data/Upload/" + Id.ToString() + Path.GetExtension(fileName); string path = Server.MapPath("~/App_Data/Upload/") + Id.ToString() + Path.GetExtension(fileName); fp.SaveAs(path); fp = null; } fp = Request.Files["motherphoto"]; if (fp != null && fp.ContentLength >= 0) { var fileName = Path.GetFileName(fp.FileName); Guid Id = Guid.NewGuid(); motherphoto = "~/App_Data/Upload/" + Id.ToString() + Path.GetExtension(fileName); string path = Server.MapPath("~/App_Data/Upload/") + Id.ToString() + Path.GetExtension(fileName); fp.SaveAs(path); fp = null; } student.MotherPhoto = motherphoto.ToString(); student.FatherPhoto = fatherphoto.ToString(); student.StudentPhoto = studentphoto.ToString(); usp_UserDetailsGet_Result userdetails = (usp_UserDetailsGet_Result)Session["LoginInfo"]; student.UserID = userdetails.UserID; using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseUrl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.PostAsJsonAsync("Student/SudentInsert", student); response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) { var studentresponse = response.Content.ReadAsStringAsync().Result; // studentList = JsonConvert.DeserializeObject<List<usp_StudentGet_Result>>(studentresponse); } } } else { RedirectToAction("CreateStudent"); } } else { return(RedirectToAction("Index", "UserLogin", new { area = "Login" })); } } catch (Exception ex) { } //List<FileDetail> fileDetails = new List<FileDetail>(); //for (int i = 0; i < Request.Files.Count; i++) //{ // var file = Request.Files[i]; // if (file != null && file.ContentLength >= 0) // { // var fileName = Path.GetFileName(file.FileName); // Guid Id = Guid.NewGuid(); // string path = Server.MapPath("~/App_Data/Upload/") + Id.ToString() + Path.GetExtension(fileName); // file.SaveAs(path); // } //} return(RedirectToAction("Index")); }