Exemplo n.º 1
0
        public async Task <ActionResult> SaveTeamNotes(string teamId, [Bind(Include = "Id, Content")] TeamNote teamNote)
        {
            PlayViewModel model = new PlayViewModel();

            teamNote.TeamId = teamId;
            if (!string.IsNullOrEmpty(teamNote.Id))
            {
                if (await model.CreateTeamNotes(teamNote))
                {
                    TempData["ErrorMessage"] = "Note added to team";
                }
                else
                {
                    TempData["ErrorMessage"] = "There is some problem in adding note to team";
                }
            }
            else
            {
                if (await model.CreateTeamNotes(teamNote))
                {
                    TempData["ErrorMessage"] = "Note updated to team";
                }
                else
                {
                    TempData["ErrorMessage"] = "There is some problem in updating note to team";
                }
            }

            ActionResult result;

            result = RedirectToAction("Install", new { teamId = teamId });
            return(await Task.FromResult(result));
        }
        public async Task <ActionResult> Library(string teamId)
        {
            PlayViewModel model = new PlayViewModel();
            await model.Load(teamId);

            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <GameViewModel> Play(PlayViewModel play)
        {
            var guid = new Guid(play.GameId);
            var game = await _gameService.Play(play.Index, guid, play.GameTimer);

            return(MapToViewModel(game));
        }
Exemplo n.º 4
0
        // GET: Pictures/Play/5
        public async Task <IActionResult> Play(int?id, int?[] type)
        {
            var userId = GetCookie("key");

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

            List <VisualFeatureTypes> featureTypes = new List <VisualFeatureTypes>();

            if (type.Count() > 0)
            {
                foreach (var itemType in type)
                {
                    var xpto = (VisualFeatureTypes)(Convert.ToInt32(itemType));
                    featureTypes.Add(xpto);
                }
            }
            else
            {
                featureTypes = features;
            }


            var picture = await _context.Picture.FirstOrDefaultAsync(m => m.PictureId == id);

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

            PictureIAService picServ = new PictureIAService(_computerVisionEndpoint, _computerVisionKey);

            string url;

            if (picture.Storage)
            {
                url = _azureStorageConfig.Url + _azureStorageConfig.ImageContainer + "/" + picture.Address;
            }
            else
            {
                url = picture.Address;
            }

            var response = await picServ.AnalyzeRemoteAsync(url, featureTypes);

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(response);

            ViewBag.ImageUrl = url;
            ViewBag.features = json;
            ViewBag.response = response;

            PlayViewModel viewModel = new PlayViewModel();

            viewModel.AnalysisReturn = response;
            viewModel.Picture        = picture;

            return(View(viewModel));
        }
Exemplo n.º 5
0
        public ActionResult Play()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(View("NotAuthorized"));
            }

            User user = gc.GetUser(User.Identity.Name);

            Board board = (from bu in gc.BoardUsers
                           where bu.UserName == user.UserName
                           select bu.Board).FirstOrDefault();

            PlayViewModel pvm = new PlayViewModel()
            {
                HasActiveGame = board != null,
                MyTurn        = false

                                // TODO:
                                // need function GetCurrentProperty(user)
            };

            if (board != null)
            {
                pvm.MyTurn = board.GetPlayerWithCurrentTurn() == user;
            }


            return(View(pvm));
        }
Exemplo n.º 6
0
        public PlayView(MasterOfSudokuViewModel sudoku)
        {
            var pageServices = new PageService();

            ViewModel = new PlayViewModel(SudokuCreator.DifficultOptions.Evil, pageServices, sudoku);
            InitializeComponent();
            Padding = new Thickness(0, 20, 0, 0);
            SetCellsInit();
            SizeChanged     += (s, e) => { ViewModel.MainWidth = Height > Width?Width:Height; SetGrides(); SetCells(); };
            lblText.Text     = ViewModel.toString;
            lblText.FontSize = 20;
            NavigationPage.SetHasNavigationBar(this, true);
            Device.StartTimer(TimeSpan.FromMilliseconds(1000), () =>
            {
                sw.Start();

                ViewModel.TimeSpan = sw.Elapsed;
                ViewModel.Time     = "Time: " + ViewModel.TimeSpan.Minutes + "m " + ViewModel.TimeSpan.Seconds + "s";

                if (!ViewModel.IsGameActive)
                {
                    sw.Reset();
                    return(false);
                }
                return(true);
            });
        }
Exemplo n.º 7
0
        public ActionResult Play(PlayViewModel character)
        {
            string gameServerUrl = System.Configuration.ConfigurationManager.AppSettings["GameServerUrl"];
            string redirectUrl   = gameServerUrl + "?token=" + HttpContext.Request.Cookies[SlowpokeHub.TokenCookieName].Value;

            return(Redirect(redirectUrl));
        }
        // GET: Play/AddNewPlay
        public ActionResult AddNewPlay()
        {
            var playViewModel = new PlayViewModel();

            playViewModel.Actors = _actorService.GetAllActors();
            return(View(playViewModel));
        }
Exemplo n.º 9
0
        private ActionResult GetPlaylist(string title, string playUrl, List <Track> tracks, Func <int, string> getPageUrl, int page)
        {
            var trackList = new TrackListViewModel(tracks, page, _appSettings.TracksPerPage, GetViewModel, getPageUrl, playUrl);

            var model = new PlayViewModel(title, trackList, playUrl);

            return(PartialView("_Playlist", model));
        }
Exemplo n.º 10
0
    private bool IsValid(PlayViewModel vm)
    {
        var validBotName          = !string.IsNullOrEmpty(vm.BotName);
        var validHealthAndStamina = vm.BotHealth > 0 && vm.BotStamina > 0 && vm.BotHealth + vm.BotStamina <= _configurationHelper.PointsLimit;
        var validScript           = vm.SelectedScript != Guid.Empty || !string.IsNullOrEmpty(vm.Script);

        return(validBotName && validHealthAndStamina && validScript);
    }
Exemplo n.º 11
0
        public IActionResult Play()
        {
            // Play Game
            IRandomNumberGenerator randomNumGen = new GetRandomNumber();
            Scorekeeper            keeper       = new Scorekeeper(ONE_DAY);
            Game game = new Game(randomNumGen);

            string[] team1 = new string[] { "Ian Botham", "Mike Gatting", "David Gower", "Joe Root", "Jos Buttler", "Ben Stokes",
                                            "Johnny Bairstow", "Stuart Broad", "Graham Swann", "Jofra Archer", "Jimmy Anderson" };
            string[] team2 = new string[] { "Michael Vaughan", "Alistair Cook", "Viv Richards", "Freddie Flintoff", "Geoff Miller", "Nasser Hussain",
                                            "Alex Stewart", "Darren Gough", "Bob Willis", "Phil Tuffnell", "Mike Hendrick" };

            keeper.ChangeBowler("Malcolm Marshall");
            keeper.SubmitTeam(0, team1);
            keeper.SubmitTeam(1, team2);

            Umpire umpey = new Umpire(game, keeper);

            umpey.playInnings();
            keeper.StartInnings(1);
            keeper.ChangeBowler("Ian Botham");
            umpey.playInnings();


            //// Map Scores to View Model
            PlayViewModel pvm = new PlayViewModel();

            var(r1, w1, b1, e1) = keeper.GetInningsScore(0);
            var(r2, w2, b2, e2) = keeper.GetInningsScore(1);


            pvm.runs = new int[2] {
                r1, r2
            };
            pvm.wickets = new int[2] {
                w1, w2
            };
            pvm.overs = new int[2] {
                b1, b2
            };
            pvm.extras = new int[2] {
                e1, e2
            };

            pvm.team1 = team1;
            pvm.team2 = team2;

            pvm.scores1 = new int[11];
            pvm.scores2 = new int[11];

            for (int i = 0; i < 11; i++)
            {
                pvm.scores1[i] = keeper.GetBatsmanScore(0, team1[i]);
                pvm.scores2[i] = keeper.GetBatsmanScore(1, team2[i]);
            }

            return(View(pvm));
        }
Exemplo n.º 12
0
        public ActionResult Index(int page = 1)
        {
            var tracklist = new TrackListViewModel(Playlist.Tracks, page, _appSettings.TracksPerPage, GetViewModel,
                                                   p => Url.Action(nameof(Index), new { page = p }), Url.Action(nameof(Restart)));

            var model = new PlayViewModel(Playlist.PlaylistName, tracklist);

            return(PartialView("_Index", model));
        }
Exemplo n.º 13
0
        public ActionResult Play(string key)
        {
            var playerId = GetPlayerId();

            var model = new PlayViewModel();

            model.SerieId = key;

            model.FirstTwoCards = new List <GameCard>();

            using (LittleGoatEntities entities = new LittleGoatEntities())
            {
                var serie = entities.Serie.FirstOrDefault(p => p.Id == key);
                if (serie == null || !serie.Started)
                {
                    return(RedirectToAction("New", "Serie", new { key }));
                }

                var currentPlayer = serie.SeriePlayers.FirstOrDefault(p => p.PlayerId == playerId);
                if (currentPlayer == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                var game = entities.Game.Single(p => p.SerieId == key && p.Ended == false);

                model.DateStopShowFirstTwoCards = game.CreationDate.AddSeconds(NB_SECONDS_TO_SHOW_FIRST_TWO_CARDS);

                if (game.CreationDate.AddSeconds(NB_SECONDS_TO_SHOW_FIRST_TWO_CARDS) >= DateTime.UtcNow)
                {
                    model.FirstTwoCards = entities.GameCard.Where(p => p.GameId == game.Id && p.PlayerId == playerId).OrderBy(p => p.Position).Take(2).ToList();
                }

                model.CardFromDeck = entities.GameCard
                                     .Where(p => p.GameId == game.Id && p.PlayerId == null)
                                     .OrderBy(p => p.Position)
                                     .FirstOrDefault();

                model.NextExpectedAction = string.Format(Resources.next_to_play_1, game.Player2.Name);

                model.LastChatMessages = entities.SerieChat
                                         .Where(p => p.SerieId == key)
                                         .OrderByDescending(p => p.Id)
                                         .Select(p => new ChatMessage()
                {
                    Id = p.Id, Date = p.Date, Message = p.Message, PlayerId = p.PlayerId, PlayerName = p.Player.Name
                })
                                         .Take(30)
                                         .OrderBy(p => p.Date)
                                         .ToList();
            }

            return(View(model));
        }
Exemplo n.º 14
0
        public IActionResult Index(int gameId)
        {
            var claimsIdentity = (ClaimsIdentity)this.User.Identity;
            var claims         = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);

            //Check if next turn is ready
            _playGame.CheckNextTurnReady(gameId);

            var notes = _unitOfWork.Note.GetAll(c => c.GameId == gameId && c.ApplicationUserId == claims.Value).ToList();

            PlayViewModel PlayVM = new PlayViewModel()
            {
                Character = _unitOfWork.GameUser.GetFirstOrDefault(filter: c => c.ApplicationUserId == claims.Value && c.GameId == gameId, includeProperties: "Game,ApplicationUser"),
                Opponents = _unitOfWork.GameUser.GetAll(filter: c => c.ApplicationUserId != claims.Value && c.GameId == gameId, includeProperties: "ApplicationUser", orderBy: q => q.OrderByDescending(c => c.IsAlive)),
                Notes     = notes,
                VoteList  = _unitOfWork.GameUser.GetAll(filter: c => c.GameId == gameId && c.IsAlive == true, includeProperties: "ApplicationUser").Select(c => c.ApplicationUser)
            };

            //Get the logs for the last turn
            PlayVM.Logs = _unitOfWork.Log.GetAll(c => c.GameId == gameId && c.Turn == PlayVM.Character.Game.TurnNumber - 1 && (c.Visible == SD.Everyone || c.Visible == PlayVM.Character.Role)).ToList();
            //PlayVM.Logs = logs.Where(c => c.Visible == SD.Everyone || c.Visible == PlayVM.Character.Role).ToList();

            //Get the already selected vote
            PlayVM.Vote = _unitOfWork.Vote.GetFirstOrDefault(c => c.ApplicationUserId == claims.Value && c.Turn == PlayVM.Character.Game.TurnNumber);
            //Get the list of already casted vote
            if (PlayVM.Character.Game.TurnType == SD.Night)
            {
                if (PlayVM.Character.Role == SD.Werewolf)
                {
                    //Get the list only for WEREWOLF for NIGHT
                    PlayVM.VoteCasted = _unitOfWork.Vote.GetAll(c => c.Role == SD.Werewolf && c.GameId == PlayVM.Character.GameId && c.Turn == PlayVM.Character.Game.TurnNumber);
                }
                else if (PlayVM.Character.Role == SD.Doctor)
                {
                    //Get the list only for DOCTOR for NIGHT
                    PlayVM.VoteCasted = _unitOfWork.Vote.GetAll(c => c.Role == SD.Doctor && c.GameId == PlayVM.Character.GameId && c.Turn == PlayVM.Character.Game.TurnNumber);
                }
                else if (PlayVM.Character.Role == SD.Seer)
                {
                    //Get the list only for SEER for NIGHT
                    PlayVM.VoteCasted = _unitOfWork.Vote.GetAll(c => c.Role == SD.Seer && c.GameId == PlayVM.Character.GameId && c.Turn == PlayVM.Character.Game.TurnNumber);
                }
            }
            else if (PlayVM.Character.Game.TurnType == SD.Day)
            {
                //get list for everyone during the Day
                PlayVM.VoteCasted = _unitOfWork.Vote.GetAll(c => c.GameId == PlayVM.Character.GameId && c.Turn == PlayVM.Character.Game.TurnNumber);
            }

            return(View(PlayVM));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> MonitoringPlays(long mode = 0, string play = "", long lottery = 0, string date = "")
        {
            DateTime df = Dates.ConverToDate(date, "es-DO");

            var plays = await _repository.GetPlays(MyCurrentUser.Get.UserId, MyCurrentUser.Get.OwnerId, mode, play, lottery, df, df);

            await FillLotteryAndLotteryModeCombo();

            var vm = new PlayViewModel();

            vm.Sale  = new LotterySale();
            vm.Items = plays;
            return(View(vm));
        }
Exemplo n.º 16
0
        public ActionResult Play(string button)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(View("NotAuthorized"));
            }

            User user = gc.GetUser(User.Identity.Name);

            Board board = (from bu in gc.BoardUsers
                           where bu.UserName == user.UserName
                           select bu.Board).FirstOrDefault();

            switch (button)
            {
            case "Roll":
            {
                if (board.GetPlayerWithCurrentTurn() == user)
                {
                    bool doubles;
                    int  roll;

                    //board.MakeCurrentPlayerMove(out doubles, out roll);
                }
                break;
            }

            case "BuyProperty": break;

            case "MortgageProperty": break;

            case "BuyHouse": break;

            case "BuyHotel": break;

            case "SellHouse": break;

            case "SellHotel": break;

            default: return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PlayViewModel pvm = new PlayViewModel()
            {
                MyTurn = false
            };

            return(View(pvm));
        }
Exemplo n.º 17
0
        public ActionResult Details(int id)
        {
            var playView = _playViewService.GetPlayView(id);
            var model    = new PlayViewModel
            {
                Id               = playView.Id,
                Title            = playView.Title,
                Description      = playView.Description,
                ScheduledTime    = playView.ScheduledTime,
                ActorsString     = playView.Actors,
                ImageVirtualPath = playView.ImageVirtualPath
            };

            return(View(model));
        }
Exemplo n.º 18
0
        public ActionResult AddNewPlay(PlayViewModel model)
        {
            if (model.SelectedActorsIds.Count == 0)
            {
                ModelState.AddModelError(nameof(PlayViewModel.SelectedActorsIds), "Please select actors for this play.");
                model.Actors = _actorService.GetAllActors();
                return(View(model));
            }

            if (ModelState.IsValid)
            {
                if (model.File.ContentLength > 0 && model.File.ContentType.Contains("image"))
                {
                    var    imageFolderPath = Server.MapPath(WebConfigurationManager.AppSettings["imagePath"].ToString());
                    var    fileName        = Guid.NewGuid().ToString();
                    string virtualPath     = string.Format("{0}{1}{2}", WebConfigurationManager.AppSettings["virtualImagePath"].ToString(), fileName, Path.GetExtension(model.File.FileName).ToLower());
                    string path            = string.Format("{0}{1}{2}", imageFolderPath, Path.GetFileName(fileName), Path.GetExtension(model.File.FileName).ToLower());
                    model.File.SaveAs(path);

                    PlayWithActors playWithActors = new PlayWithActors
                    {
                        Title            = model.Title,
                        ImagePath        = path,
                        ImageVirtualPath = virtualPath,
                        ImageType        = Path.GetExtension(model.File.FileName),
                        Description      = model.Description,
                        ScheduledTime    = model.ScheduledTime,
                        ActorsIds        = model.SelectedActorsIds
                    };

                    _playService.CreatePlay(playWithActors);

                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError(nameof(PlayViewModel.File), "File must be image type!");
                    model.Actors = _actorService.GetAllActors();
                    return(View(model));
                }
            }
            else
            {
                model.Actors = _actorService.GetAllActors();
                return(View(model));
            }
        }
Exemplo n.º 19
0
        public async Task <ActionResult> GetTeamNoteDetail(string teamId, string Id)
        {
            try
            {
                var viewModel = new PlayViewModel();
                await viewModel.Load(teamId);

                var teamNote = viewModel.TeamNotes.TeamNotes.FirstOrDefault(x => x.Id == Id);
                ViewData["TeamId"] = teamId;
                ViewData["Id"]     = Id;
                return(PartialView("_AddEditTeamNotes", teamNote));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 20
0
        public PlayPage(int indexOfQuestion)
        {
            InitializeComponent();

            var vm = new PlayViewModel(this.Navigation, indexOfQuestion);

            this.BindingContext = vm;

            this.LabelNumber.SetBinding(Label.TextProperty,
                                        new Binding(PlayViewModel.NumberPropertyName, BindingMode.OneWay));

            this.LabelNumber.SetBinding(Label.FontProperty,
                                        new Binding(PlayViewModel.IsStartingPropertyName, BindingMode.OneWay,
                                                    new DelegateValueConverter <bool, Font>(x => x ?
                                                                                            Font.SystemFontOfSize(Style.FontSizeBiggest) :
                                                                                            Font.SystemFontOfSize(Style.FontSizeBig), null)));
        }
Exemplo n.º 21
0
        public IActionResult CreatePlay(PlayViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(nameof(CreatePlay), model));
            }

            var result = this.playService.AddPlay(model.Name);

            if (result)
            {
                return(Redirect(nameof(Plays)));
            }

            model.StatusMessage = MessageConstants.PlayWithSameNameExist;

            return(View(nameof(CreatePlay), model));
        }
Exemplo n.º 22
0
        public async Task <IActionResult> GetItemsToDisplayDetail(string playedNumber, long lotteryId, long modeId)
        {
            var owner = MyCurrentUser.Get.OwnerId;
            var plays = await _repository.GetPlaysFilter("", owner, modeId, playedNumber, lotteryId, DateTime.Now);

            var vm = new PlayViewModel();

            vm.Sale   = new LotterySale();
            vm.Items  = plays;
            vm.Number = playedNumber;
            var lttery = await _repository.GetLotery(lotteryId);

            vm.Lottery = lttery.Name;
            var mode = await _repository.GetMode(modeId);

            vm.Mode = mode.Code;
            return(PartialView("_TicketDetailsByNumberPartial", vm));
        }
Exemplo n.º 23
0
        public IActionResult Template()
        {
            if (HttpContext.Session.Keys.Contains("PLAYER"))
            {
                var player = HttpContext.Session.GetObject <PlayerDto>("PLAYER");
                var vm     = new PlayViewModel
                {
                    PlayerName = player.Name,
                    BotName    = "<name your bot>",
                    BotHealth  = 100,
                    BotStamina = 100,
                    Scripts    = BotScripts.All
                };
                return(View(vm));
            }

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 24
0
        public async Task <ActionResult> DeleteTeamNotesById(string id, string teamId)
        {
            //var viewModel = new TeamViewModel();
            PlayViewModel viewModel = new PlayViewModel();

            if (await viewModel.DeleteTeamNotesById(id))
            {
                TempData["ErrorMessage"] = "Team Note is deleted";
            }
            else
            {
                TempData["ErrorMessage"] = "There is some problem in deleting team Note";
            }

            ActionResult result;

            result = RedirectToAction("Install", new { teamId = teamId });
            return(await Task.FromResult(result));
        }
Exemplo n.º 25
0
        public IActionResult Edit(PlayViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model.Id));
            }

            var result = this.playService.Edit(
                model.Id,
                model.Name);

            if (result)
            {
                StatusMessage = MessageConstants.PlayWasChanged;

                return(RedirectToAction(nameof(Edit), new { id = model.Id }));
            }

            return(View(model));
        }
Exemplo n.º 26
0
    public async Task <IActionResult> Template()
    {
        if (HttpContext.Session.Keys.Contains("PLAYER"))
        {
            var player = HttpContext.Session.GetObject <PlayerDto>("PLAYER");
            var vm     = new PlayViewModel
            {
                PlayerName = player.Name,
                BotName    = "<name your bot>",
                BotHealth  = 100,
                BotStamina = 100,
                Scripts    = await _templateLogic.GetAllTemplates()
            };
            ViewData["ArenaUrl"]          = _configuration.GetValue <string>("ARENA_URL");
            ViewData["ScriptTemplateUrl"] = _configuration.GetValue <string>("SCRIPT_TEMPLATE_URL");
            return(View(vm));
        }

        return(RedirectToAction("Index", "Home"));
    }
Exemplo n.º 27
0
        public ActionResult Play(int id = 0)
        {
            using (var galleristContext = new GalleristComponentsDbContext())
            {
                var gameResponse = GameManager.GetGame(id, galleristContext);

                if (gameResponse.Success && gameResponse.Game.IsStarted)
                {
                    var userName  = User.Identity.Name;
                    var playModel = new PlayViewModel(userName, gameResponse.Game);
                    return(View(playModel));
                }
                else
                {
                    ViewBag.Message = gameResponse.Message;
                    ViewBag.Title   = gameResponse.Title;
                    return(View("GameError"));
                }
            }
        }
Exemplo n.º 28
0
 private void OnNavigation(string destination)
 {
     switch (destination)
     {
         case "play":
             CurrentViewModel = new PlayViewModel();
             break;
         case "player":
             CurrentViewModel = new PlayerViewModel();
             break;
         case "customize":
             CurrentViewModel = new CustomizeViewModel();
             break;
         case "statistics":
             CurrentViewModel = new StatisticsViewModel();
             break;
         default:
             throw new ArgumentException($"Failed to navigate to '{destination}', the destination was not recognized");
     }
 }
Exemplo n.º 29
0
        // GET: Quiz/Play/5
        public async Task <IActionResult> Play(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }

            var quiz = await _quizRepository.GetQuizById(id);

            if (quiz == null)
            {
                return(NotFound($"Quiz id {id} does not exist."));
            }

            var questions = _questionRepository.GetAllByQuizId(id);

            if (questions == null)
            {
                return(NotFound($"There are no questions for Quiz id {id}."));
            }

            //var answers = await _context.Answers.ToListAsync();

            foreach (var question in questions)
            {
                question.Answers = new List <Answer>();

                question.Answers = _answerRepository.GetAllByQuestionId(question.QuestionId) as List <Answer>;

                // Applying extension method to produce random list
                question.Answers.Shuffle();
            }

            var model = new PlayViewModel
            {
                Quiz      = quiz,
                Questions = questions,
            };

            return(View(model));
        }
Exemplo n.º 30
0
        // GET: Play
        public ActionResult Index()
        {
            currentUser = db.Users.Where(u => u.Email == User.Identity.Name).FirstOrDefault();


            var playViewModel = new PlayViewModel();

            //Load Current User Details
            var x = db.Users.Where(u => u.Email == User.Identity.Name);

            playViewModel.currentUser.user        = currentUser;
            playViewModel.currentUser.userDetails = db.UserDetails.FirstOrDefault(u => u.userID == User.Identity.Name);

            //Load the Nearby Users
            var userLocation = new Location(double.Parse(currentUser.Lat), double.Parse(currentUser.Lon));
            var neighbors    = GetNeighbors(userLocation);

            playViewModel.nearbyUsers = neighbors;

            return(View(playViewModel));
        }
Exemplo n.º 31
0
        public async Task <ActionResult> Play(int gameId, string turnResult = "")
        {
            var game = GameRepository.Get(gameId);

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

            var user = await UserManager.GetUserAsync(User);

            var pwm = new PlayViewModel
            {
                User      = user,
                GameId    = gameId,
                GameState = game.Game.GameState,
                Lifes     = game.GetLifes(user),
                Result    = turnResult
            };

            return(View(pwm));
        }
Exemplo n.º 32
0
 /// <summary>
 /// 播放视频
 /// </summary>
 /// <param name="ResourceId"></param>
 /// <returns>return View("Play");</returns>
 public async Task<ActionResult> Play(string ResourceId)
 {
     ViewBag.Title = "在线观看";
     PlayViewModel viewModel = new PlayViewModel();
     viewModel.Resource = await ResourceService.getResourceById(ResourceId);
     Session["CourseId"] = viewModel.Resource.Course.CourseId;
     viewModel.Group = await ResourceGroupService.GetResourceGroupByGroupId(viewModel.Resource.ResourceGroup.GroupId);
     MarkModel Lovemodel = new MarkModel();
     if (Session["LoginUser"] != null)
     {
         Lovemodel.User = Session["LoginUser"] as UserModel;
         MarkModel Learnmodel = new MarkModel();
         Learnmodel.User = Session["LoginUser"] as UserModel;
         Learnmodel.MarkType = await MarkTypeService.getMarkTypeByTypeName("观看");
         Learnmodel.Resource = await ResourceService.getResourceById(ResourceId);
         if (!await MarkService.MarkIsExist(Learnmodel))
         {
             await MarkService.CreatLearned(Learnmodel);
         }
         Lovemodel.MarkType = await MarkTypeService.getMarkTypeByTypeName("收藏");
         Lovemodel.Resource = await ResourceService.getResourceById(ResourceId);
         if (await MarkService.MarkIsExist(Lovemodel))
         {
             viewModel.IsLove = true;
         }
         else
         {
             viewModel.IsLove = false;
         }
     }
     if (viewModel.Group.GroupName.ToString().Trim() != "不分组")
     {
         viewModel.GroupResourceList = await ResourceService.getResourceByGroup(viewModel.Group.GroupId);
     }
     else
     {
         viewModel.GroupResourceList = new List<ResourceModel>();
     }
     return View("Play", viewModel);
 }