public async Task <IActionResult> Create(PieDetailCreateViewModel pieDetail) { if (ModelState.IsValid) { var pieDetailId = await _pieDetailRepository.Add(_mapper.Map <PieDetailCreateViewModel, PieDetail>(pieDetail)); return(RedirectToAction("New", "Catalog", pieDetailId)); } return(View(pieDetail)); }
public async Task <IActionResult> Create(PieDetailCreateViewModel pieDetail) { if (ModelState.IsValid) { await _pieDetailRepository.Add(_mapper.Map <PieDetailCreateViewModel, PieDetail>(pieDetail)); return(RedirectToAction("AllProducts", "Admin")); } return(View(pieDetail)); }
public async Task <IActionResult> AddPieDetail(string name) { var result = new PieDetail { Name = name.ToTitleCase() }; try { var pieDetail = await _pieDetailRepository.Add(result); return(Ok(new { pieDetail })); } catch { return(BadRequest()); } }