public ActionResult Delete(string Id) { Repository repository = new Repository(); FertilityModel fertilityModel = repository.GetFertilityModel(Id); return(View(fertilityModel)); }
static void DisabledMain(string[] args) { try { List <string> rowListFertility = RowListFromFile(new StreamReader(@"xfe.csv", Encoding.UTF8)); List <string> rowListIq = RowListFromFile(new StreamReader(@"xiq.csv", Encoding.UTF8)); Repository repository = new Repository(); foreach (string row in rowListFertility) { string[] data = row.Split(','); FertilityModel fertilityModel = new FertilityModel(data[0], ConvertOrNull(data[1]), ConvertOrNull(data[2]), null); //repository.AddData(fertilityModel); *** disabled to prevent accidental repopulation of db } foreach (string row in rowListIq) { string[] data = row.Split(','); FertilityModel fertilityModel = new FertilityModel(data[0], null, null, ConvertOrNull(data[1])); //repository.AddData(fertilityModel); *** disabled to prevent accidental repopulation of db } Console.WriteLine("Ultimate success. Check database"); } catch { Console.WriteLine("Something went wrong, Boss..."); } finally { Console.ReadKey(); } }
public ActionResult Delete(FertilityModel fertilityModel) { Repository repository = new Repository(); try { repository.Delete(fertilityModel); } catch { ViewBag.ValidationMessage = "Something went wrong with the validation of this object. Please correct and try again."; return(View(fertilityModel.Id)); } return(RedirectToAction("Index")); }
public ActionResult Create() { FertilityModel fertilityModel = new FertilityModel(); return(View(fertilityModel)); }