public async Task <IActionResult> Create(CategoryNewModel item) { if (ModelState.IsValid) { Guid id = await _categoryFacade.Create(item); return(RedirectToAction(nameof(Index), new { area = "Admin" })); } return(View(item)); }
public static Category ToCategoryDbModel(CategoryNewModel newModel) { var dbModel = new Category { Name = newModel.Name, Description = newModel.Description, Image = FromFileForm(newModel.Image) }; return(dbModel); }
async public Task <IActionResult> Create(CategoryNewModel category) { if (ModelState.IsValid) { Console.WriteLine("Model valid!"); var dbModel = DataMapper.ModelMapper.ToCategoryDbModel(category); await _categoryRepository.Add(dbModel); await _categoryRepository.SaveChangesAsync(); } else { Console.WriteLine("Model invalid!"); return(View("New", category)); } return(RedirectToAction("Index", "Home")); }
public IActionResult New() { var categoryNewModel = new CategoryNewModel(); return(View(categoryNewModel)); }
public Guid Create(CategoryNewModel category) { var categoryEntity = mapper.Map <CategoryEntity>(category); return(categoryRepository.Insert(categoryEntity)); }
public ActionResult <Guid> Create(CategoryNewModel category) { return(categoryFacade.Create(category)); }