Example #1
0
        public IActionResult Update(long id, [FromBody] AnnonceService item)
        {
            if (item == null)
            {
                return(BadRequest());
            }
            var AnnonceServiceObj = _context.annonceServices.Find(id);

            if (AnnonceServiceObj == null)
            {
                return(NotFound());
            }
            var itemToUpdate = _context.annonceServices.SingleOrDefault(r => r.Id == id);

            if (itemToUpdate != null)
            {
                itemToUpdate.Titre = item.Titre;
                itemToUpdate.DisponibiliteService = item.DisponibiliteService;
                itemToUpdate.DescriptionBesoin    = item.DescriptionBesoin;
                itemToUpdate.Description          = item.Description;
                itemToUpdate.DatePublication      = item.DatePublication;
                itemToUpdate.Cout = item.Cout;
            }
            _context.SaveChanges();

            return(new NoContentResult());
        }
Example #2
0
 public IActionResult Create([FromBody] AnnonceService item)
 {
     if (item == null)
     {
         return(BadRequest());
     }
     _context.annonceServices.Add(item);
     _context.SaveChanges();
     return(CreatedAtRoute("GetAnnonceService", new { id = item.Id }, item));
 }
 public ContratsController()
 {
     contratService = new ContratService();
     userService    = new UserService();
     annonceService = new AnnonceService();
 }