public IActionResult Index(int forceNumber) { var r = new List <Officer>(); if (forceNumber != 0) { var result = officer.SearchByForceNumber(forceNumber); if (result != null) { r.Add(result); return(View(r)); } else { ViewBag.Message = "Force number not found in the System"; ViewBag.MessageType = "Warining"; return(View(r)); } } else { return(View(officer.GetAll())); } }
public IActionResult Create(Case model) { ViewBag.OffenceID = new SelectList(offence.GetAll(), "OffenseID", "Name"); ViewBag.OfficerID = new SelectList(officer.GetAll(), "OfficerID", "ForceNumber"); if (model.DateOfArrest != null && model.CourtDate != null) { if (model.CourtDate < model.DateOfArrest) { ViewBag.Message = "Court date cannot be earlier than the date of arrest"; ViewBag.MessageType = "Warining"; return(View(model)); } else { model.CaseStatusID = 1; model.Officer = officer.SearchByForceNumber(model.Officer.ForceNumber); caseOps.Insert(model); return(RedirectToAction("Index")); } } else { model.CaseStatusID = 1; var _officer = officer.SearchByForceNumber(model.Officer.ForceNumber); if (_officer != null) { model.Officer = _officer; caseOps.Insert(model); return(RedirectToAction("Index")); } else { ViewBag.Message = "Officer force number not found"; ViewBag.MessageType = "Warining"; return(View(model)); } } }