public async Task <IActionResult> RecordAdd([FromBody] SelectRecord record)
        {
            int a = _record.GetCount(x => x.CourseID == record.CourseID && x.StudentID == record.StudentID);

            if (a > 0)
            {
                return(new JsonResult(new { code = ResultCode.错误, message = "已选过该课程,请确认后再提交" }));
            }
            record.ID             = Guid.NewGuid();
            record.CreateBy       = (Guid)record.LastUpdateBy;
            record.CreateTime     = DateTime.Now;
            record.LastUpdateTime = DateTime.Now;
            record.IsDelete       = false;
            try
            {
                await _record.AddAsync(record);

                _redis.Set("recordList", record.ID.ToString(), record);
            }
            catch (Exception e)
            {
                return(new JsonResult(new { code = ResultCode.错误, message = e.Message }));
            }
            return(new JsonResult(new { code = ResultCode.正常 }));
        }
        public async Task AddAsync(SelectRecord entity)
        {
            _context.Add(entity);
            await _context.SaveChangesAsync();

            _context.DetachAll();
        }
        public void Delete(Expression <Func <SelectRecord, bool> > where)
        {
            SelectRecord entity = _context.SelectRecord.Where(where).FirstOrDefault();

            entity.IsDelete = true;
            _context.Update(entity);
            _context.SaveChanges();
        }
 public void Update(SelectRecord entity)
 {
     _context.Update(entity);
     _context.SaveChanges();
     _context.DetachAll();
 }
 public void Add(SelectRecord entity)
 {
     _context.Add(entity);
     _context.SaveChanges();
     _context.DetachAll();
 }