Vous êtes sur la page 1sur 4

Etape 1 :

Temchi taayet lel les interfacesService mteaaik ili hachtekk behom exemple :
IOffreService offreService;
IEntrepriseService entrepriseService;

Etape 2 :
Tamel Constructeur : ekteb cotr ( double tabulation yjik fonction )
public OffreController(IOffreService o, IEntrepriseService entrepriseService)
{
this.offreService = o;
this.entrepriseService = entrepriseService;
}

Etape 3
Ken aandek ajout roulant maneha haja haka :

// GET: *****Controller/Create

public ActionResult Create()


{
ViewBag.EntrepriseFK = new SelectList(entrepriseService.GetAll(), "IdEntreprise",
"NomEntreprise");

return View();
}

Tafsiiiiiiiiiiiiiir :
EntrepriseFK : temchi lel entité offre o declarer thot

[ForeignKey("Entreprise")]

public int EntrepriseFK {get ;set ;}

IdEntreprise : esm id entreprise f classe entreprise (asl)

NomEntreprise ; chnia l’attribut ili theb thotou f liste roulante


Etape 4

// POST: OffreController1/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(Offre o)
{

OffreService.Add(o);
OffreService.Commit();
return RedirectToAction(nameof(Index));

Etape 5
Creation vue :
Etape 6
Fi ficher ili taamal taht view f west esm entité ili amltha create.cshtml
Thabetttt lenaaa :
Kima declarineha f
Nfsha win aamalna
entité etape 3
ajout roulant f get
create

Etape 7
Click droite o jareeeeb baed mtamel l’ajout chiuf f base o dima réfrechi

Vous aimerez peut-être aussi