Example #1
0
        public async Task <OptionModel> Update(OptionUpdateModel model)
        {
            var entity = _mapper.Map <Option>(model);

            //not async since i am assuming we need the record immediately after
            _context.Options.Attach(entity);
            _context.Entry(entity).State = EntityState.Modified;
            await SaveAsync();

            return(_mapper.Map <OptionModel>(entity));
        }
Example #2
0
        public async Task <SurveyUserModelBase> Update(SurveyUserUpdateModel model)
        {
            var entity = _mapper.Map <SurveyUser>(model);

            _context.SurveyUsers.Attach(entity);
            _context.Entry(entity).State = EntityState.Modified;

            await SaveAsync();

            return(_mapper.Map <SurveyUserModelBase>(entity));
        }
        public async Task <QuestionModelBase> Update(QuestionUpdateModel model)
        {
            var entity = await _context.Questions.FindAsync(model.Id);

            if (entity == null)
            {
                throw new Exception("Question not found");
            }
            _mapper.Map(model, entity);

            _context.Questions.Attach(entity);
            _context.Entry(entity).State = EntityState.Modified;
            await SaveAsync();

            return(_mapper.Map <QuestionModelBase>(entity));
        }
        public async Task <AnswersBaseModel> Update(AnswersUpdateModel model)
        {
            var entity = await _context.Answers.FindAsync(model.Id);

            if (entity == null)
            {
                throw new Exception("Answer not found");
            }
            _mapper.Map(model, entity);

            _context.Answers.Attach(entity);
            _context.Entry(entity).State = EntityState.Modified;
            await SaveAsync();

            return(_mapper.Map <AnswersBaseModel>(entity));
        }