public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } await _directorService.Create(DirectorCreation); return(RedirectToPage("/Index")); }
public ActionResult Create(DirectorViewModel directorViewModel, HttpPostedFileBase image) { if (ModelState.IsValid) { directorViewModel.Id = Guid.NewGuid(); Director director = Mapper.Map <Director>(directorViewModel); if (image != null) { if (CheckImageUploadExtension.CheckImagePath(image.FileName) == true) { var path = Path.Combine(Server.MapPath("~/Images/Upload"), image.FileName); image.SaveAs(path); director.Thumbnail = VariableUtils.UrlUpLoadImage + image.FileName; } } _directorService.Create(director); return(RedirectToAction("Index")); } return(PartialView("_CreateDirector", directorViewModel)); }
public async Task Create(DirectorInputDto inputDto) { await DirectorService.Create(inputDto); }