Пример #1
0
        public async Task <IActionResult> UnPublishSituation([FromRoute] int id)
        {
            SituationsDto result = await _situationService.UnPublishSituation(id);

            if (result != null)
            {
                return(Ok(result));
            }
            return(NotFound());
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }