public DtoActivite(Activite activite) { Id = activite.Id; Nom = activite.Nom; Prix = activite.Prix; Description = activite.Description; Adresse = activite.Adresse; HeureDuJour = activite.HeureDuJour; }
public IHttpActionResult PostActivite(DtoCreateActivite dtoCreateActivite) { if (!ModelState.IsValid) { return BadRequest(ModelState); } Activite activite = new Activite(); activite.Prix = dtoCreateActivite.Prix; activite.Nom = dtoCreateActivite.Nom; activite.Description = dtoCreateActivite.Description; activite.Adresse = dtoCreateActivite.Adresse; activite.HeureDuJour = dtoCreateActivite.HeureDuJour; Jour jour = db.Jours.Where(u => u.Id.Equals(dtoCreateActivite.JourId)).FirstOrDefault(); activite.Jour = jour; db.Activites.Add(activite); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = activite.Id }, new DtoActivite(activite)); }