Exemple #1
0
        public async Task <Result <int> > CreateVideoWithBaseInformation(CreateVideoDTO createVideoViewModel)
        {
            var uri = API.Video.CreateVideoWithBaseInformation();

            var json = JsonConvert.SerializeObject(createVideoViewModel);

            var content = new StringContent(json, Encoding.UTF8, "application/json");

            var response = await _httpClient.PostAsync(uri, content);

            if (!response.IsSuccessStatusCode)
            {
                return(new Result <int>()
                {
                    IsSuccessStatusCode = false
                });
            }

            var jsonResponse = await response.Content.ReadAsStringAsync();

            var createdVideoId = JsonConvert.DeserializeObject <int>(jsonResponse);

            return(new Result <int>()
            {
                IsSuccessStatusCode = true,
                Content = createdVideoId
            });
        }
Exemple #2
0
        public async Task <ActionResult <int> > Create([FromBody] CreateVideoDTO video)
        {
            var request  = _mapper.Map <CreateVideoRequestMessage>(video);
            var response = await _mediator.Send(request);

            if (response.VideoId == null)
            {
                return(NoContent());
            }

            return(Ok(response.VideoId));
        }