Esempio n. 1
0
        public async Task ModifyAnswerAsync(Answer ans)
        {
            try
            {
                if (ans.Author == null)
                {
                    throw new InvalidOperationException("No User is logged in");
                }

                var e    = Mapper.MapAnswer(ans);
                var oldQ = _context.Answers.Where(x => x.Id == ans.ID).FirstOrDefault();

                _context.Entry(oldQ).CurrentValues.SetValues(e);
                await _context.SaveChangesAsync();
            }
            catch
            {
                throw new InvalidOperationException("There is no such answer to the question existed");
            }
        }