public OperateRecordDTO Add(OperateRecordDTO operateRecordDTO, bool commit = true) { var record = operateRecordDTO.ToModel(); record.Id = IdentityGenerator.NewSequentialGuid(); if (record.OperateTime == DateTime.MinValue) { record.OperateTime = DateTime.UtcNow; } if (record.Message != null && record.Message.Length > 150) { var message = record.Message; record.Message = record.Message.Substring(0, 147) + "..."; // 把message添加到Extend表 var extend = new OperateRecordExtend() { Id = IdentityGenerator.NewSequentialGuid(), LongMessage = message }; record.ExtendId = extend.Id; _Repository.AddExtend(extend); } _Repository.Add(record); if (commit) { //commit the unit of work _Repository.UnitOfWork.Commit(); } return(record.ToDto()); }
public OperateRecordExtend AddExtend(OperateRecordExtend item) { var unitOfWork = (this.UnitOfWork as RuicoUnitOfWork); unitOfWork.OperateRecordExtends.Add(item); return(item); }
public static OperateRecordExtendDTO ToDto(this OperateRecordExtend model) { return(Mapper.Map <OperateRecordExtendDTO>(model)); }