public async Task <ActionResult> AddReply(string id, IFormFile file, ReplyViewModel reply) { Post post = new Post() { Title = reply.Title, Content = reply.Content, MediaDescription = reply.MediaDescription, UserId = reply.UserId, UserName = reply.UserName, CreatedDate = DateTime.Now }; try { if (file != null) { using (var filestream = file.OpenReadStream()) { post.MediaUrl = await _mediaService.UploadMediaAsync(filestream, file.FileName, file.ContentType); post.MediaType = file.ContentType; } } var topic = await _storeService.AddTopicReply(id, post); return(Ok(new ResultViewModel() { Result = Result.SUCCESS, Data = topic })); } catch (Exception ex) { return(Ok(new ResultViewModel() { Result = Result.ERROR, Message = ex.Message })); } }