示例#1
0
        public ActionResult Index()
        {
            var users   = _usersRepository.Get();
            var devices = _devicesRepository.Get();
            var videos  = _videosRepository.Get();


            var usersViewModels = new List <UserViewModel>();

            foreach (var user in users)
            {
                usersViewModels.Add(new UserViewModel
                {
                    Id      = user.Id,
                    Name    = user.Name,
                    Devices = _devicesRepository.Get(user.Id)
                });
            }

            var vm = new AdministratorPageViewModel
            {
                Users   = usersViewModels.ToArray(),
                Devices = devices,
                Videos  = videos
            };

            return(View(vm));
        }
示例#2
0
        public async Task <IActionResult> GetVideo(string id)
        {
            var video = await _repository.Get(id.ToString());

            if (video == null)
            {
                return(NotFound());
            }

            return(Ok(_mapper.Map <Video>(video)));
        }
 public RedirectResult Delete(string name)
 {
     _videosRepository.Delete(_videosRepository.Get(name));
     return(Redirect("/Admin/Index"));
 }