Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpGet]
- public ActionResult DierBewerken(int id)
- {
- DierInfoService dierinfoservice = new DierInfoService();
- var nieuweform = new DierInfoGrootForm();
- List<Identificatie> identificatielijst = dierinfoservice.GetIdentificatieViaId(id);
- List<IdentificatieInfo> identificatieinfoLijst = new List<IdentificatieInfo>();
- foreach (Identificatie identificiatie in identificatielijst)
- {
- if (identificiatie.TypeIdentificatie == "CHIP")
- { typeidentificatie = IdentificatieInfo.TypeIdentificatieEnum.CHIP; }
- else
- { typeidentificatie = IdentificatieInfo.TypeIdentificatieEnum.TATOEAGE; }
- if (identificiatie.TatoeagePlaats == "NEK")
- {
- tatoeageplaats = IdentificatieInfo.IdentificiatiePlaats.NEK;
- }
- else if (identificiatie.TatoeagePlaats == "OOR")
- {
- tatoeageplaats = IdentificatieInfo.IdentificiatiePlaats.OOR;
- }
- else if (identificiatie.TatoeagePlaats == "BIL")
- {
- tatoeageplaats = IdentificatieInfo.IdentificiatiePlaats.BIL;
- }
- else
- {
- tatoeageplaats = null;
- }
- if (identificiatie.TatoeageAanduiding == "LINKS")
- {
- tatoeageaanduiding = IdentificatieInfo.IdentificiatieAanduiding.LINKS;
- }
- else if (identificiatie.TatoeageAanduiding == "RECHTS")
- {
- tatoeageaanduiding = IdentificatieInfo.IdentificiatieAanduiding.RECHTS;
- }
- else
- {
- tatoeageaanduiding = null;
- }
- if (identificiatie.ChipPlaats == "NEK")
- {
- chipplaats = IdentificatieInfo.IdentificiatiePlaats.NEK;
- }
- else if (identificiatie.ChipPlaats == "OOR")
- {
- chipplaats = IdentificatieInfo.IdentificiatiePlaats.OOR;
- }
- else if (identificiatie.ChipPlaats == "BIL")
- {
- chipplaats = IdentificatieInfo.IdentificiatiePlaats.BIL;
- }
- else
- {
- chipplaats = null;
- }
- if (identificiatie.ChipAanduiding == "LINKS")
- {
- chipaanduiding = IdentificatieInfo.IdentificiatieAanduiding.LINKS;
- }
- else if (identificiatie.ChipAanduiding == "RECHTS")
- {
- chipaanduiding = IdentificatieInfo.IdentificiatieAanduiding.RECHTS;
- }
- else
- {
- chipaanduiding = null;
- }
- identificatieinfoLijst.Add(
- new IdentificatieInfo(identificiatie.IdentificatieID, typeidentificatie, identificiatie.TatoeageNummer, tatoeageplaats,
- tatoeageaanduiding, identificiatie.ChipNummer, chipplaats, chipaanduiding));
- }
- List<FysischeKenmerkenInfo> fysischeKenmerkeninfoKortLijst = new List<FysischeKenmerkenInfo>();
- fysischeKenmerkeninfoKortLijst = dierinfoservice.GetFysischeKenmerkenKortViaId(id);
- string NUllwaarde;
- int NUllID;
- Dier dier = db.Dier.Find(id);
- //var fysischeKenmerken = db.FysischeKenmerken.Where(m => m.Dier_DierID == id).ToList();
- DierInfo dierinfo = new DierInfo();
- if (dier.Ras1 == null)
- {
- NUllwaarde = "";
- NUllID = 0;
- }
- else
- {
- NUllwaarde = dier.Ras1.RasNaam;
- NUllID = (int)dier.Ras_RasIDKruising;
- }
- dierinfo.DierID = id;
- dierinfo.Diernaam = dier.Diernaam;
- dierinfo.Geboortdatum = dier.Geboortdatum;
- dierinfo.Geslacht = dier.Geslacht;
- dierinfo.Kruising = dier.Kruising;
- dierinfo.VermoedelijkeGeboortejaar = dier.VermoedelijkeGeboortejaar;
- dierinfo.RasID2 = NUllID;
- dierinfo.RasID = dier.Ras_RasID;
- //ViewBag.HerkenningsObject_HerkenningsObjectID = new SelectList(db.HerkenningsObject, "HerkenningsObjectID", "HerkenningsObjectKenmerk" , ); ;
- ViewBag.Ras_RasID = new SelectList(db.Ras, "RasID", "RasNaam", dier.Ras_RasID);
- ViewBag.Ras_RasIDKruising = new SelectList(db.Ras, "RasID", "RasNaam", dier.Ras_RasIDKruising);
- //ViewBag.Ras_RasID = new SelectList(db.HerkenningsObject, "HerkenningsObjectID", "HerkenningsObjectKenmerk", fysischeKenmerken. );
- //ViewBag.Ras_RasIDKruising = new SelectList(db.Ras, "RasID", "RasNaam", dier.Ras_RasIDKruising);
- nieuweform.Identificatieinfos = identificatieinfoLijst;
- nieuweform.FysischeKenmerkenInfos = fysischeKenmerkeninfoKortLijst;
- nieuweform.Dierinfo = dierinfo;
- nieuweform.NieuweFysischeKenmerkenInfos = new List<FysischeKenmerkenInfo>();
- nieuweform.NieuweIdentificatieinfos = new List<IdentificatieInfo>();
- return View(nieuweform);
- }
- [HttpPost]
- //[ValidateAntiForgeryToken]
- public ActionResult DierBewerken(DierInfoGrootForm form)
- //public ActionResult DierBewerken([Bind(Include = "DierID,Ras_RasID,Kruising,Ras_RasIDKruising,Diernaam,Geboortdatum,VermoedelijkeGeboortejaar,Geslacht")] Dier dier)
- {
- if (ModelState.IsValid)
- {
- foreach (var item in form.Identificatieinfos)
- {
- Identificatie identificatie = new Identificatie
- {
- Dier_DierID = form.Dierinfo.DierID,
- IdentificatieDatum = DateTime.Now,
- IdentificatieID = item.IdentificatieID,
- TypeIdentificatie = item.TypeIdentificatieEnumeration.ToString(),
- TatoeageNummer = item.TatoeageNummer,
- TatoeagePlaats = item.TatoeagePlaats.ToString() ?? null,
- TatoeageAanduiding = item.TatoeageAanduiding.ToString() ?? null,
- ChipNummer = item.ChipNummer,
- ChipPlaats = item.ChipPlaats.ToString() ?? null,
- ChipAanduiding = item.ChipAanduiding.ToString() ?? null
- };
- db.Entry(identificatie).State = EntityState.Modified;
- }
- Dier dier = new Dier
- {
- DierID = form.Dierinfo.DierID,
- Diernaam = form.Dierinfo.Diernaam,
- Geslacht = form.Dierinfo.Geslacht,
- Kruising = form.Dierinfo.Kruising,
- Ras_RasID = form.Dierinfo.RasID,
- Ras_RasIDKruising = form.Dierinfo.RasID2,
- Geboortdatum = form.Dierinfo.Geboortdatum,
- VermoedelijkeGeboortejaar = form.Dierinfo.VermoedelijkeGeboortejaar
- };
- db.Entry(dier).State = EntityState.Modified;
- db.SaveChanges();
- return RedirectToAction("OverzichtDieren");
- }
- //ViewBag.Ras_RasID = new SelectList(db.Ras, "RasID", "RasNaam", dier.Ras_RasID);
- //ViewBag.Ras_RasIDKruising = new SelectList(db.Ras, "RasID", "RasNaam", dier.Ras_RasIDKruising);
- return View(form);
- //return View(dier);
- }
- namespace Dierenasiel_MVC_Eindwerk.Models
- {
- public class DierInfoGrootForm
- {
- public int DierId { get; set; }
- public DierInfo Dierinfo { get; set; }
- public List<IdentificatieInfo> Identificatieinfos { get; set; }
- public List<FysischeKenmerkenInfo> FysischeKenmerkenInfos { get; set; }
- public List<IdentificatieInfo> NieuweIdentificatieinfos { get; set; }
- public List<FysischeKenmerkenInfo> NieuweFysischeKenmerkenInfos { get; set; }
- public List<Herkenningsobjecten> Herkenningsobjectens { get; set; }
- }
- }
- @for (int index = 0; index < Model.Identificatieinfos.Count(); index++)
- {
- @Html.HiddenFor(model => model.Identificatieinfos[index].IdentificatieID)
- <tr>
- <th scope="row">@(index + 1)</th>
- @*<td>@Html.EditorFor(model => model.Identificatieinfos[i], new { htmlAttributes = new { @class = "form-control" } })</td>*@
- @*<td>@Html.DropDownListFor(m => m.Identificatieinfos[i].TypeEn , new SelectList( Enum.GetValues() )),"Selecteer identificatie")</td>*@
- <td>
- @Html.EnumDropDownListFor(model => model.Identificatieinfos[index].TypeIdentificatieEnumeration, "Selecteer identificatie", new { @class = "fields-select form-control" ,
- @onchange = "onSelectChange(this , index);"
- })
- </td>
- @if (@Model.Identificatieinfos[index].TypeIdentificatieEnumeration.ToString() == "CHIP")
- {
- <td>@Html.EditorFor(model => model.Identificatieinfos[index].ChipNummer, new { htmlAttributes = new { @class = "form-control" } })</td>
- <td>@Html.EnumDropDownListFor(model => model.Identificatieinfos[index].ChipPlaats, "Selecteer de plaats", new { @class = "fields-select form-control" })</td>
- <td>@Html.EnumDropDownListFor(model => model.Identificatieinfos[index].ChipAanduiding, "Selecteer de positie", new { @class = "fields-select form-control" })</td>
- <td class="d-none">@Html.EditorFor(model => model.Identificatieinfos[index].TatoeageNummer, new { htmlAttributes = new { @class = "form-control" } })</td>
- <td class="d-none">@Html.EnumDropDownListFor(model => model.Identificatieinfos[index].TatoeagePlaats, "Selecteer de plaats", new { @class = "fields-select form-control" })</td>
- <td class="d-none">@Html.EnumDropDownListFor(model => model.Identificatieinfos[index].TatoeageAanduiding, "Selecteer de positie", new { @class = "fields-select form-control" })</td>
- }
- else if (@Model.Identificatieinfos[index].TypeIdentificatieEnumeration.ToString() == "TATOEAGE")
- {
- <td class="d-none">@Html.EditorFor(model => model.Identificatieinfos[index].ChipNummer, new { htmlAttributes = new { @class = "form-control" } })</td>
- <td class="d-none">@Html.EnumDropDownListFor(model => model.Identificatieinfos[index].ChipPlaats, "Selecteer de plaats", new { @class = "fields-select form-control" })</td>
- <td class="d-none">@Html.EnumDropDownListFor(model => model.Identificatieinfos[index].ChipAanduiding, "Selecteer de positie", new { @class = "fields-select form-control" })</td>
- <td>@Html.EditorFor(model => model.Identificatieinfos[index].TatoeageNummer, new { htmlAttributes = new { @class = "form-control" } })</td>
- <td>@Html.EnumDropDownListFor(model => model.Identificatieinfos[index].TatoeagePlaats, "Selecteer de plaats", new { @class = "fields-select form-control" })</td>
- <td>@Html.EnumDropDownListFor(model => model.Identificatieinfos[index].TatoeageAanduiding, "Selecteer de positie", new { @class = "fields-select form-control" })</td>
- }
- </tr>
- //index++;
- }
- <tr class="col" id="IdentificatieToevoegen">
- <th scope="row">#</th>
- <td colspan="4">
- <div class="btn btn-friendly form-control text-left" name="1" value="1">@Html.ActionLink("Identificatie toevoegen", "DierBewerken", new { Bijvoegen = "identificatie" })</div>
- </td>
- </tr>
- </tbody>
- </table>
- @*@Model.NieuweIdentificatieinfos.Add(new Dierenasiel_MVC_Eindwerk.Models.HerdefinerenClasses.IdentificatieInfo("TATOEAGE", "15qsdq14", "NEK", "LINKS", null, null, null))*@
- @*Dierenasiel_MVC_Eindwerk.Models.HerdefinerenClasses.IdentificatieInfo.TypeIdentificatieEnum.TATOEAGE*@
- @*//new Dierenasiel_MVC_Eindwerk.Models.HerdefinerenClasses.IdentificatieInfo.TypeIdentificatieEnum.*@
- </div> @*div table identificatie*@
- @if (Model.NieuweIdentificatieinfos.Count() > 0)
- {
- <div class="form-group col">
- <table class="table table-striped">
- <thead>
- <tr>
- <th scope="col">#</th>
- <th scope="col">Type identificatie</th>
- <th scope="col">Nummer</th>
- <th scope="col">Plaats</th>
- <th scope="col">Zijde</th>
- </tr>
- </thead>
- <tbody>
- @for (int index = 0; index < Model.NieuweIdentificatieinfos.Count(); index++)
- //foreach (var item in @ViewBag.IdentificatieinfoLijst)
- {
- @*@Html.HiddenFor(model => model.NieuweIdentificatieinfos[index].IdentificatieID)*@
- <tr>
- <th scope="row">@(index + 1)</th>
- @*<td>@Html.EditorFor(model => model.Identificatieinfos[i], new { htmlAttributes = new { @class = "form-control" } })</td>*@
- @*<td>@Html.DropDownListFor(m => m.Identificatieinfos[i].TypeEn , new SelectList( Enum.GetValues() )),"Selecteer identificatie")</td>*@
- <td>
- @Html.EnumDropDownListFor(model => model.NieuweIdentificatieinfos[index].TypeIdentificatieEnumeration, "Selecteer identificatie", new { @class = "fields-select form-control" ,
- @onchange = "onSelectChange(this , index);"
- })
- </td>
- @if (@Model.NieuweIdentificatieinfos[index].TypeIdentificatieEnumeration.ToString() == "CHIP")
- {
- <td>@Html.EditorFor(model => model.NieuweIdentificatieinfos[index].ChipNummer, new { htmlAttributes = new { @class = "form-control" } })</td>
- <td>@Html.EnumDropDownListFor(model => model.NieuweIdentificatieinfos[index].ChipPlaats, "Selecteer de plaats", new { @class = "fields-select form-control" })</td>
- <td>@Html.EnumDropDownListFor(model => model.NieuweIdentificatieinfos[index].ChipAanduiding, "Selecteer de positie", new { @class = "fields-select form-control" })</td>
- <td class="d-none">@Html.EditorFor(model => model.NieuweIdentificatieinfos[index].TatoeageNummer, new { htmlAttributes = new { @class = "form-control" } })</td>
- <td class="d-none">@Html.EnumDropDownListFor(model => model.NieuweIdentificatieinfos[index].TatoeagePlaats, "Selecteer de plaats", new { @class = "fields-select form-control" })</td>
- <td class="d-none">@Html.EnumDropDownListFor(model => model.NieuweIdentificatieinfos[index].TatoeageAanduiding, "Selecteer de positie", new { @class = "fields-select form-control" })</td>
- }
- else if (@Model.NieuweIdentificatieinfos[index].TypeIdentificatieEnumeration.ToString() == "TATOEAGE")
- {
- <td class="d-none">@Html.EditorFor(model => model.NieuweIdentificatieinfos[index].ChipNummer, new { htmlAttributes = new { @class = "form-control" } })</td>
- <td class="d-none">@Html.EnumDropDownListFor(model => model.NieuweIdentificatieinfos[index].ChipPlaats, "Selecteer de plaats", new { @class = "fields-select form-control" })</td>
- <td class="d-none">@Html.EnumDropDownListFor(model => model.NieuweIdentificatieinfos[index].ChipAanduiding, "Selecteer de positie", new { @class = "fields-select form-control" })</td>
- <td>@Html.EditorFor(model => model.NieuweIdentificatieinfos[index].TatoeageNummer, new { htmlAttributes = new { @class = "form-control" } })</td>
- <td>@Html.EnumDropDownListFor(model => model.NieuweIdentificatieinfos[index].TatoeagePlaats, "Selecteer de plaats", new { @class = "fields-select form-control" })</td>
- <td>@Html.EnumDropDownListFor(model => model.NieuweIdentificatieinfos[index].TatoeageAanduiding, "Selecteer de positie", new { @class = "fields-select form-control" })</td>
- }
- </tr>
- //index++;
- }
- </tbody>
- </table>
- </div> @*div table identificatie*@
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement