public async Task <IHttpActionResult> Create([FromBody, CustomizeValidator(RuleSet = "AddContent, default")] ContentWeb contentWeb) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var sub = (User as ClaimsPrincipal).FindFirst("sub"); string subString = sub.Value; var user = (await Uservice.GetByIdAsync(subString)); if (user.IsSuccess == true) { var userId = user.Data; var contentLogic = mapper.Map <ContentWeb, ContentLogic>(contentWeb); var result = await service.AddAsync(contentLogic, userId); if (result.IsSuccess == true) { return(Ok(contentWeb)); } else { return(BadRequest(result.Message)); } } else { return(Unauthorized()); } } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <MContentResult <ContentDto> > AddContent([FromBody] ContentDto contentDto) { return(await _service.AddAsync(contentDto)); }