Model
public partial class Assignment
{
public Assignment()
{
this.CourseAvailables = new HashSet();
List svaVozila = new List();
using (StreamReader sr = new StreamReader(@"C:\proba\MvcApplication1\MvcApplication1\fajlovi\vozila.txt"))
{
while (sr.Peek() >= 0)
{
string str;
string[] strArray;
str = sr.ReadLine();
strArray = str.Split('|');
Vozila auto = new Vozila();
auto.Registracija = strArray[0];
auto.Marka = strArray[1];
auto.GodinaProiz = strArray[2];
auto.Boja = strArray[3];
svaVozila.Add(auto);
}
}
string registracija = Request.Form["registracija"];
string datum = Request.Form["Datum"];
string odM = Request["odMesta"];
string doM = Request.Form["doMesta"];
string kilometara = Request.Form["kilometara"];
if (!String.IsNullOrEmpty(registracija))
{
using (StreamWriter wr = new StreamWriter(@"C:\proba\MvcApplication1\MvcApplication1\fajlovi\" + registracija + ".txt", true))
{
wr.WriteLine(registracija + "|" + datum + "|" + odM + "|" + doM + "|" + kilometara);
}
}
return View(svaVozila);
}
public ActionResult Prikaz()
{
List svaVozila = new List();
using (StreamReader sr = new StreamReader(@"C:\proba\MvcApplication1\MvcApplication1\fajlovi\vozila.txt"))
{
while (sr.Peek() >= 0)
{
string str;
string[] strArray;
str = sr.ReadLine();
strArray = str.Split('|');
Vozila auto = new Vozila();
auto.Registracija = strArray[0];
auto.Marka = strArray[1];
auto.GodinaProiz = strArray[2];
auto.Boja = strArray[3];
svaVozila.Add(auto);
}
}
string reg = Request["reg"];
string Marka = "";
string godia = "";
int kilometri = 0;
for (int i = 0; i < svaVozila.Count; i++)
{
if (svaVozila[i].Registracija == reg)
{
Marka = svaVozila[i].Marka;
godia = svaVozila[i].GodinaProiz;
}
}
if (!String.IsNullOrEmpty(reg))
{
List predj = new List();
using (StreamReader sr = new StreamReader(@"C:\proba\MvcApplication1\MvcApplication1\fajlovi\" + reg + ".txt"))
{
while (sr.Peek() >= 0)
{
string str;
string[] strArray;
str = sr.ReadLine();
strArray = str.Split('|');
PredjeniPut put = new PredjeniPut();
put.Registracija = strArray[0];
put.Datum = strArray[1];
put.Odmesta = strArray[2];
put.Domesta = strArray[3];
put.Kilometara = Convert.ToInt32(strArray[4]);
predj.Add(put);
}
}
for (int i = 0; i < predj.Count; i++)
{
kilometri += predj[i].Kilometara;
}
}
ViewData["Kilometri"] = kilometri;
ViewData["reg"] = reg;
ViewData["Marka"] = Marka;
ViewData["godina"] = godia;
return View(svaVozila);
}
}
}
@*@model List
@{
ViewBag.Title = "Index";
}
Index
@using (Html.BeginForm("index,home"))
{
}
@Html.ActionLink("Prikaz","Prikaz","home");*@
@*@model List
@{
ViewBag.Title = "Prikaz";
}
Prikaz
@using (Html.BeginForm("Prikaz,home"))
{
Registracija
GodinaProizvodnje
Marka
Kilometri
@ViewData["reg"]
@ViewData["Godina"]
@ViewData["Marka"]
@ViewData["Kilometri"]
}
*@