public async Task <IActionResult> Put([FromBody] BulletinDto bulletinDto) { var bulletin = Mapper.Map <Bulletin>(bulletinDto); await Executor.GetCommand <UpdateBulletinCommand>().Process(c => c.ExecuteAsync(bulletin)); return(NoContent()); }
public IActionResult RemoveBulletin(int id) { Bulletin bulletinToRemove = _bulletinManager.GetBulletin(id); Bulletin removedBulletin = _bulletinManager.RemoveBulletin(bulletinToRemove); BulletinDto removedBulletinDto = _mapper.Map <BulletinDto>(removedBulletin); return(Ok(removedBulletinDto)); }
public async Task <IActionResult> Post([FromBody] BulletinDto bulletinDto) { var bulletin = Mapper.Map <Bulletin>(bulletinDto); Executor.GetHandler <GenerateBulletinNumberHandler>() .Process <string>(h => h.Execute(bulletin)); var bulletinId = await Executor.GetCommand <CreateBulletinCommand>().Process(c => c.ExecuteAsync(bulletin)); return(Ok(bulletinId)); }
public IActionResult NewBulletin([FromBody] BulletinDto bulletinDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Bulletin bulletin = _mapper.Map <Bulletin>(bulletinDto); Bulletin savedBulletin = _bulletinManager.SaveNewBulletin(bulletin, User); string url = Url.Action("GetBulletin", "Bulletin", new { id = bulletin.Id }); BulletinDto savedBulletinDto = _mapper.Map <BulletinDto>(savedBulletin); return(Created(url, savedBulletinDto)); }
public IActionResult ReplaceBulletin(int id, [FromBody] Bulletin bulletin) { Bulletin bulletinToReplace = _bulletinManager.GetBulletin(id); if (bulletinToReplace != null) { _bulletinManager.Detach(bulletinToReplace); } if (ModelState.IsValid && bulletinToReplace != null) { bulletinToReplace.Title = bulletin.Title; bulletinToReplace.Content = bulletin.Content; Bulletin bulletinReplaced = _bulletinManager.ReplaceBulletin(bulletinToReplace); BulletinDto bulletinReplacedDto = _mapper.Map <BulletinDto>(bulletinReplaced); return(Ok(bulletinReplacedDto)); } else { return(BadRequest()); } }