public async Task <IActionResult> UnPublishSituation([FromRoute] int id) { SituationsDto result = await _situationService.UnPublishSituation(id); if (result != null) { return(Ok(result)); } return(NotFound()); }
public async Task <SituationsDto> GetSituationByID(int id) { Situations situations = await _context.Situations .Include(x => x.SituationHandicaps) .Include(x => x.SituationAttributes) .Include(x => x.SituationQuestions).ThenInclude(situation => situation.Answers) .Include(x => x.SituationCategory) .Include(x => x.ImageFile) .Include(x => x.Book) .Where(x => x.Id == id && x.Deleted == false).FirstOrDefaultAsync(); SituationsDto result = _mapper.Map <Situations, SituationsDto>(situations); return(result); }
public async Task <SituationsDto> UnPublishSituation(int id) { Situations situations = await _context.Situations .Where(x => x.Id == id).FirstOrDefaultAsync(); if (situations != null && situations.Deleted == false) { situations.Published = false; situations.Unpublished = true; _context.Entry(situations).State = EntityState.Modified; await _context.SaveChangesAsync(); SituationsDto result = _mapper.Map <Situations, SituationsDto>(situations); return(result); } return(null); }