Ejemplo n.º 1
0
        public async Task <ActionResult> CreateRating(UserSongViewModel vm)
        {
            var addRating = new AddRatingViewModel
            {
                UserId  = vm.UserId,
                SongId  = vm.SongId,
                Value   = vm.Value,
                RatedOn = DateTime.Today
            };

            var request = CreateGet(HttpMethod.Post, "api/rating/addrating");

            request.Content = new ObjectContent <AddRatingViewModel>(addRating, new JsonMediaTypeFormatter());

            var result = await HttpClient.SendAsync(request);

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> RateSong()
        {
            var request = CreateGet(HttpMethod.Get, "api/inventory/song");

            var result = await HttpClient.SendAsync(request);

            var vm = await result.Content.ReadAsAsync <IEnumerable <SongViewModel> >();


            var userRequest = CreateGet(HttpMethod.Get, "api/Account/User");
            var userResult  = await HttpClient.SendAsync(userRequest);

            var userVm = await userResult.Content.ReadAsAsync <IEnumerable <UserViewModel> >();

            var viewModel = new UserSongViewModel(userVm, vm);

            return(View(viewModel));
        }