Ejemplo n.º 1
0
 /// <summary>
 /// 新增一条示例数据
 /// </summary>
 /// <param name="dto">实体</param>
 /// <returns>实体</returns>
 public SampleUpdateDto CreateSample(SampleCreateDto dto)
 {
     using (_unitOfWork.BeginTransaction())
     {
         var entity  = Mapper.Map <Sample>(dto);
         var entity2 = new User()
         {
             Id   = "123123122211111",
             Age  = 11,
             Name = "测试"
         };
         entity.Id = Guid.NewGuid();
         var insertEntity = _repository.Insert(entity);
         _userRepository.Insert(entity2);
         _unitOfWork.Save();
         return(Mapper.Map <SampleUpdateDto>(insertEntity));
     }
 }
Ejemplo n.º 2
0
        public IActionResult Post([FromBody] SampleCreateDto dto)
        {
            var result = _service.CreateSample(dto);

            return(Ok(result));
        }