public async Task <IActionResult> PostThread(PostThreadDTO postThreadDTO) { Console.WriteLine(postThreadDTO); ServiceResponse <GetThreadDTO> response = await _threadService.PostThread( postThreadDTO, this.User.FindFirst(ClaimTypes.NameIdentifier).Value); return(response.ReturnResult()); }
public async Task <ServiceResponse <GetThreadDTO> > PostThread(PostThreadDTO postThreadDTO, string userId) { ServiceResponse <GetThreadDTO> response = new ServiceResponse <GetThreadDTO>(); var createdThread = await _context.Threads.AddAsync(new Thread { Title = postThreadDTO.Title, User = await _context.Users.FirstOrDefaultAsync(u => u.Auth == userId), Category = await _context.Categories.FirstOrDefaultAsync(c => c.Id == int.Parse(postThreadDTO.Id)), }); await _context.SaveChangesAsync(); response.Data = _mapper.Map <GetThreadDTO>(createdThread.Entity); return(response); }