using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Eyepax.Test.WebClient.Controllers
{
public class TestStudentController : Controller
{
// Create a DB Object for retriew data from DB
ServiceReferenceTest.StudentServiceClient serviceObj = new ServiceReferenceTest.StudentServiceClient();
//
// GET: /TestStudent/
public ActionResult Index()
{
List<Eyepax.Test.Model.Test> model = serviceObj.GetTests(null).ToList();
return View(model);
}
//
// GET: /TestStudent/Details/5
public ActionResult Details(int id)
{
return View();
}
//
// GET: /TestStudent/Create
public ActionResult Create()
{
return View();
}
//
// POST: /TestStudent/Create
[HttpPost]
public ActionResult Create(Eyepax.Test.Model.Test collection)
{
try
{
// TODO: Add insert logic here
serviceObj.CreateTest(collection);
return RedirectToAction("Index");
}
catch
{
return View();
}
}
//
// GET: /TestStudent/Edit/5
public ActionResult Edit(int id)
{
return View();
}
//
// POST: /TestStudent/Edit/5
[HttpPost]
public ActionResult Edit(int id, FormCollection collection)
{
try
{
// TODO: Add update logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
//
// GET: /TestStudent/Delete/5
public ActionResult Delete(int id)
{
return View();
}
//
// POST: /TestStudent/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
try
{
// TODO: Add delete logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
public JsonResult GetStudentDonations(int id, string loggedUsre)
{
try
{
decimal StudentDonation = 0;
StudentDonation = serviceObj.GetDonationDetails(id);
if (StudentDonation > 100)
return Json(new { Donation = StudentDonation, Success = true }, JsonRequestBehavior.AllowGet);
else
return Json(new { Donation = StudentDonation, Success = false }, JsonRequestBehavior.AllowGet);
}
catch (Exception)
{
throw;
}
}
public JsonResult GetStateList(string countryCode)
{
IList _result = new List();
IEnumerable defaults = ReadXML().Descendants("CountryOrRegion");
var nodes = from e in defaults
where e.Attribute("Code").Value.Equals(countryCode)
from element in e.Elements()
select element;
foreach (var node in nodes)
{
_result.Add(new SelectListItem
{
Value = (string)node.Attribute("Code"),
Text = (string)node.Attribute("Name"),
});
}
return Json(_result, JsonRequestBehavior.AllowGet);
}
}
}