public async Task <TipoRecursoDTO> Create(TipoRecursoDTO dto) { var entities = _mapper.Map <TipoRecurso>(dto); entities.CreationDate = DateTime.Now; entities.Active = true; entities = await _tipoRecursoRepository.Insert(entities); return(_mapper.Map <TipoRecursoDTO>(entities)); }
public async Task <IActionResult> Update(int id, TipoRecursoDTO dto) { if (ModelState.IsValid) { dto = await _tipoRecursoService.Update(id, dto); return(Ok(dto)); } else { return(BadRequest(ModelState)); } }
public async Task <TipoRecursoDTO> Update(int id, TipoRecursoDTO dto) { var oldentity = await _tipoRecursoRepository.GetById(id); var entity = _mapper.Map <TipoRecurso>(dto); entity.Active = true; entity.UpdateDate = DateTime.Now; entity.UpdateUserId = 1; entity.CreationDate = oldentity.CreationDate; entity = await _tipoRecursoRepository.Update(id, entity); return(_mapper.Map <TipoRecursoDTO>(entity)); }