public async Task CreateTheme(ForumThemeDto theme, string ownerId) { //Theme owner theme.OwnerId = ownerId; var themeEntity = mapper.Mapper.Map <ForumTheme>(theme); await forumThemesRepository.Create(themeEntity); }
public async Task <IActionResult> Create([FromBody] ForumThemeDto dto) { dto.AuthorId = User.GetUserId(); var model = await _forumThemeService.CreateAsync(dto); return(Ok(model)); }
public async Task <IActionResult> Update(int id, [FromBody] ForumThemeDto dto) { // if (id != dto.Id) { // return BadRequest(); } var model = await _forumThemeService.UpdateAsync(dto); return(Ok(model)); }
public async Task <ForumThemeDto> CreateAsync(ForumThemeDto dto) { var model = _mapper.Map <ForumTheme>(dto); model.LastMessageAdditionTime = DateTime.Now; model.LastAnswerUserId = model.AuthorId; // model. model = await _forumThemeRepository.AddAsync(model); return(_mapper.Map <ForumThemeDto>(model)); }
public async Task <ActionResult> Create(ForumThemeDto model) { if (!ModelState.IsValid) { return(View(model)); } //Save to database await themesService.CreateTheme(model, User.Identity.GetUserId()); return(RedirectToAction("Index")); }
public async Task<ForumThemeDto> CreateAsync(ForumThemeDto dto) { var model = _mapper.Map<ForumTheme>(dto); model.LastMessageAdditionTime = DateTime.Now; model.LastAnswerUserId = model.AuthorId; // model. model = await _forumThemeRepository.AddAsync(model); await _forumThemeRepository.SaveChangesAsync(); return _mapper.Map<ForumThemeDto>(model); }
public async Task<ForumThemeDto> UpdateAsync(ForumThemeDto dto) { var theme = await _forumThemeRepository.GetByIdAsync(dto.Id); if (theme == null) { return null; } var model = _mapper.Map<ForumTheme>(dto); theme.Name = model.Name; theme.SubsectionId = model.SubsectionId; theme.Description = model.Description; _forumThemeRepository.Update(theme); await _forumThemeRepository.SaveChangesAsync(); return _mapper.Map<ForumThemeDto>(theme); }
public async Task <ForumThemeDto> UpdateAsync(ForumThemeDto dto) { var theme = await _forumThemeRepository.GetByIdAsync(dto.Id); if (theme == null) { return(null); } var model = _mapper.Map <ForumTheme>(dto); theme.Name = model.Name; theme.SubsectionId = model.SubsectionId; theme.Description = model.Description; await _forumThemeRepository.UpdateAsync(theme); return(_mapper.Map <ForumThemeDto>(theme)); }