public IActionResult Index() { TreaterModel model = new TreaterModel(); model.TreaterList = _TreaterRepository.GetList(); model.CandyList = _CandyRepository.GetList(); model.CostumeList = _CostumeRepository.GetList(); return(View(model)); }
public IActionResult Index() { ViewBag.TreaterSettings = _Settings; TreaterModel model = new TreaterModel { CandyList = new List <Candy>(_candyRepo.GetList()), CostumeList = new List <Costume>(_costumeRepo.GetList()), TreaterList = new List <Treater>(_treaterRepo.GetList()) }; return(View(model)); }
public IActionResult Create(TreaterModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Index", model)); } model.CostumeName = _CostumeRepository.GetList().Select(m => m).First(m => m.id == model.CostumeID).costume; model.CandyName = _CandyRepository.GetList().Select(m => m).First(m => m.id == model.CandyID).productName; _TreaterRepository.Insert(model.GetTreaterObject()); return(RedirectToAction("Index")); }
public static TreaterModel GetTreaterModel(this Treater treater) { TreaterModel model = new TreaterModel(); model.TreaterID = treater.id; model.TreaterName = treater.name; model.CandyID = treater.favoriteCandy.id; model.CandyName = treater.favoriteCandy.productName; model.CostumeID = treater.costume.id; model.CostumeName = treater.costume.costume; return(model); }
public static Treater GetTreaterObject(this TreaterModel model) { Treater treater = new Treater(); treater.id = model.TreaterID; treater.name = model.TreaterName; treater.favoriteCandy = new Candy(); treater.favoriteCandy.id = model.CandyID; treater.favoriteCandy.productName = model.CandyName; treater.costume = new Costume(); treater.costume.id = model.CostumeID; treater.costume.costume = model.CostumeName; return(treater); }
public IActionResult Index(TreaterModel model) { if (!ModelState.IsValid) { return(View(model)); } Treater treater = new Treater { Name = model.Name, FavoriteCandyID = model.FavoriteCandyID, CostumeID = model.CostumeID }; _treaterRepo.Insert(treater); return(RedirectToAction("Index")); }