示例#1
0
        public void CreateStudentAnswer(ModelStudentAnswer model)
        {
            using (var transaction = _ctx.Database.BeginTransaction())
            {
                try
                {
                    model.StudentAnswerActive = true;

                    var entity = model.ToEntity();

                    _ctx.Insert(entity);
                    _ctx.SaveChanges();

                    transaction.Commit();
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw new ArgumentException(e.Message);
                }
            }
        }