public IActionResult Create(CreatePersonViewModel model) { try { // TODO: Add insert logic here // TODO: Add insert logic here //if (ModelState.IsValid) //{ UploadFile upload = new UploadFile(_hosting); string uniqueFileName = upload.UploadedFile(model.image, @"wwwroot\images\People"); _repository.AddNew(new Coach() { Adresse = model.Adresse, CreatedBy = User.Identity.Name, DateOfBirth = model.DateOfBirth, First_Name = model.First_Name, Last_Name = model.Last_Name, genre = model.genre, image = uniqueFileName, Phone = model.Phone }); return(RedirectToAction(nameof(Index)).WithSuccess("Ajouter", "vous avez ajouté avec succès ")); //} //return View().WithDanger("Ajouter", "Echeq d'ajout !!!"); } catch (AjouterException e) { return(View().WithDanger("ERREUR", e.Message)); } }