public async Task <IHttpActionResult> Create([FromBody, CustomizeValidator(RuleSet = "AddAudio, default")] AudioWeb audioWeb) { 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 audiologic = mapper.Map <AudioWeb, AudioLogic>(audioWeb); var result = await service.AddAsync(audiologic, userId); if (result.IsSuccess == true) { await bus.SendAsync("Podcasts", $"Added Audio {audioWeb.Name} to {audioWeb.Course.Name} by {userId.Name}"); return(Ok(audiologic)); } else { return(BadRequest(result.Message)); } } else { return(Unauthorized()); } } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IActionResult> Upload(IFormFile audio) { await audioService.AddAsync(audio); return(Ok()); }