public void TestHandleSave_NonForcedNameChanged() { // Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam(); team.Name = "Test Team #1"; team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); DummyTeam team2 = team.Clone(); string expectedName = "Test Team #2"; team2.Name = expectedName; // Action App.Current.EventsBroker.Publish(new UpdateEvent <Team> () { Object = team2, Force = false }); // Assert mockDialogs.Verify(m => m.QuestionMessage(It.IsAny <string> (), null, It.IsAny <DummyTemplatesController> ()), Times.Once()); Assert.AreEqual(templatesController.ViewModel.ViewModels.First(x => x.ID == team.ID).Name, expectedName); Assert.IsFalse(templatesController.ViewModel.SaveCommand.CanExecute()); }
public IActionResult CreateTeam(TeamVM newTeam) { if (!ModelState.IsValid) { throw new Exception("Model invalid"); } int userId = 0; if (Int32.TryParse(HttpContext.Session.GetString("UserId"), out userId)) { var request = new CreateTeamRequest { Team = new Team { TeamName = newTeam.TeamName }, UserId = userId }; var response = service.CreateTeam(request); if (response.Success) { return(RedirectToAction("UserDashboard")); } ViewBag.Error = response.ErrorMessage; } return(View()); }
public void Search_TemplateExist_TemplateFound() { //Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam { Name = "Dummy" }; team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); //Act var evt = new SearchEvent { TextFilter = "Dummy" }; // Action App.Current.EventsBroker.Publish(evt); //Assert Assert.AreEqual(1, templatesController.ViewModel.VisibleViewModels.Count); Assert.AreEqual("Dummy", templatesController.ViewModel.VisibleViewModels.FirstOrDefault().Name); }
public void TestHandleSave_ForcedNameChanged() { // Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam(); team.Name = "Test Team #1"; team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); DummyTeam team2 = team.Clone(); string expectedName = "Test Team #2"; team2.Name = expectedName; // Action App.Current.EventsBroker.Publish(new UpdateEvent <Team> () { Object = team2, Force = true }); // Assert Assert.AreEqual(templatesController.ViewModel.ViewModels.First(x => x.ID == team.ID).Name, expectedName); Assert.IsFalse(templatesController.ViewModel.SaveCommand.CanExecute()); }
public IActionResult TeamDashboard(int teamId) { if (HttpContext.Session.GetString("UserId") != null) { ViewBag.UserName = HttpContext.Session.GetString("UserName"); var request = new GetTeamByIdRequest { TeamId = teamId }; var response = service.GetTeamById(request); var team = new TeamVM { TeamId = teamId, TeamName = response.Team.TeamName }; var teamMembers = new List <TeamMemberVm>(); foreach (var member in response.Members) { teamMembers.Add(new TeamMemberVm { UserId = member.UserId, UserName = member.UserName, UserRole = member.UserRole }); } team.TeamMembers = teamMembers; return(View(team)); } return(RedirectToAction("Login")); }
public void Search_TemplateThatDoesntExist_VisibleViewModelsEmpty() { //Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam { Name = "Dummy" }; team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); //Act var evt = new SearchEvent { TextFilter = "This doesn't exist" }; // Action App.Current.EventsBroker.Publish(evt); //Assert Assert.AreEqual(0, templatesController.ViewModel.VisibleViewModels.Count); }
public ActionResult Team(int id) { var team = Context.EventTeams.GetById(id); var vm = new TeamVM { Name = team.Name, Users = team.Users.Select(u => new UserVM { FirstName = u.FirstName, Id = u.Id, LastName = u.LastName, UserName = u.UserName, SkillRatings = u.UserSkills.Select(us => new SkillRatingVM { Rating = us.Ratings.Average(r => r.Mark), Name = us.Skill.Name }) }), //SkillNames = team.Event.Skills.Select(s => s.Name) TODO: Only get skills from event not all in users }; vm.SkillNames = vm.Users.First().SkillRatings.Select(x => x.Name).ToList(); return(View(vm)); }
public ActionResult MenuHeader() { var vm = new UserMenuHeaderVM(); try { var user = repo.GetUser(UserID); if (user != null) { vm.UserDisplayName = user.FirstName; vm.UserAvatarHash = UserService.GetAvatarUrl(user.Avatar); var teams = repo.GetTeams(UserID).ToList(); foreach (var team in teams) { var teamVM = new TeamVM { Id = team.ID, Name = team.Name }; vm.Teams.Add(teamVM); if (team.ID == TeamID) { vm.CurrentTeamName = team.Name; } } vm.SelectedTeam = TeamID; } } catch (Exception ex) { log.Error(ex); } return(PartialView("Partial/MenuHeader", vm)); }
public IHttpActionResult JoinTeam(TeamVM objTeamInfo) { StringBuilder traceLog = null; ServiceResponse <bool> objResponse = null; try { traceLog = new StringBuilder(); traceLog.AppendLine("Start: JoinTeam() Request Data:-TrainerId-" + objTeamInfo.TeamId); objResponse = new ServiceResponse <bool>(); objResponse.jsonData = TeamBL.JoinTeam(objTeamInfo); objResponse.IsResultTrue = true; return(Ok(objResponse)); } catch (Exception ex) { LogManager.LogManagerInstance.WriteErrorLog(ex); return(BadRequest(ex.Message)); } finally { traceLog.AppendLine("End:JoinTeam() Response Data-" + objResponse.IsResultTrue + ",Joined Datetime" + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); traceLog = null; } }
public void TestHandleSave_SaveStatic() { // Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam(); team.Name = "Test Team #1"; team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); DummyTeam team2 = team.Clone(); string expectedName = "Test Team #2"; team2.Name = expectedName; team2.Static = true; var evt = new UpdateEvent <Team> () { Object = team2, Force = true }; // Action App.Current.EventsBroker.Publish(evt); // Assert mockDialogs.Verify(m => m.QuestionMessage(It.IsAny <string> (), null, It.IsAny <DummyTemplatesController> ()), Times.Once()); }
public TeamInformation(int idTeam) { InitializeComponent(); TeamVM teamVM = new TeamVM(idTeam); BindingContext = teamVM; }
void Select(TeamVM teamVM) { TreeIter iter; if (GetIterFromTeam(teamVM, out iter)) { teamseditortreeview.Selection.SelectIter(iter); } }
void Remove(TeamVM teamVM) { TreeIter iter; if (GetIterFromTeam(teamVM, out iter)) { teamsStore.Remove(ref iter); teamVM.PropertyChanged -= HandleTeamPropertyChanged; } }
internal static Dictionary <string, string> CreateTeam(TeamVM team) { var response = new Dictionary <string, string>(); if (string.IsNullOrEmpty(team.TeamName)) { response.Add("teamname", "Team name cannot be null"); } return(response); }
public static TeamVM MapToVM(Team team) { TeamVM teamVM = new TeamVM() { Image = team.Image, Name = team.Name, TeamId = team.TeamId, Acronym = team.Acronym }; return(teamVM); }
public static Team MapFromVM(TeamVM teamVM) { Team team = new Team() { Image = teamVM.Image, Name = teamVM.Name, TeamId = teamVM.TeamId, Acronym = teamVM.Acronym }; return(team); }
public void TestExport_TemplateSelectedToNewFile_Exported() { // Arrange TeamVM team = PrepareExport(); // Act templatesController.ViewModel.ExportCommand.Execute(); var exportedTeam = Serializer.Instance.Load <DummyTeam> (tempFile); // Assert Assert.AreEqual(team.Model, exportedTeam); }
public async Task <ActionResult> Detail(int id) { var team = await _teamsService.GetById(id); if (team == null) { return(NotFound()); } TeamVM teamVM = _mapper.Map <TeamVM>(team); return(View(teamVM)); }
public ActionResult Edit(int id) { var team = teamManager.GetTeam(id); if (team != null) { var vm = new TeamVM { Name = team.Name, Id = team.Id }; return(PartialView(vm)); } return(View("NotFound")); }
bool GetIterFromTeam(TeamVM team, out TreeIter iter) { teamsStore.GetIterFirst(out iter); while (teamsStore.IterIsValid(iter)) { if ((teamsStore.GetValue(iter, COL_TEAM) as TeamVM).Model.Equals(team.Model)) { return(true); } teamsStore.IterNext(ref iter); } return(false); }
public string Put([FromBody] Fixture entity) { if (_fixtureService.Update(entity)) { TeamVM tvm = new TeamVM(); tvm.Team1Id = entity.Home; tvm.Team2Id = entity.Away; tvm.Team1Score = entity.HomeScore; tvm.Team2Score = entity.AwayScore; _teamService.UpdatePoint(tvm); } return(string.Empty); }
public IActionResult View(int id) { var team = this._teamManager.GetTeam(id); if (team != null) { var vm = new TeamVM { Id = team.Id, Name = team.Name, IsPublic = team.IsPublic, IsRequestingUserTeamOwner = team.IsRequestingUserTeamOwner }; return(View(vm)); } return(View("NotFound")); }
public bool UpdatePoint(TeamVM entity) { var homeTeam = Get(entity.Team1Id); homeTeam.Point += entity.PointHome; homeTeam.ChangeDate = DateTime.Now; var awayTeam = Get(entity.Team2Id); awayTeam.Point += entity.PointAway; awayTeam.ChangeDate = DateTime.Now; return((context.SaveChanges() > 0) ? true : false); }
public GetFavouriteTeamTaskResponse GetFavouriteTeamTask(GetFavouriteTeamTaskRequest request) { FavouriteTeamSettingsModel favouriteTeamSettingsModel = this.GetFavouriteTeamSettings(); //Convert from json if (favouriteTeamSettingsModel == null) { return(new GetFavouriteTeamTaskResponse()); } TeamVM favouriteTeam = favouriteTeamSettingsModel.Items.Where(x => x.Cup.Name == request.Cup.Name).Select(x => x.Team).FirstOrDefault(); return(new GetFavouriteTeamTaskResponse()//Objekt upakiraj u response i vrati ga nazad { Team = favouriteTeam }); }
public ActionResult ViewRoster(int id) { var leagueManager = new LeagueManager(); var manager = new TeamManager(); var roster = manager.GetTeamById(id); var teamVM = new TeamVM(); teamVM.Team = roster; teamVM.TeamLeague = leagueManager.GetLeagueById(teamVM.Team.LeagueId); teamVM.FreeAgents = manager.GetTeamById(0); teamVM.Team.Players = roster.Players.OrderBy(t => t.LastName).ToList(); return(View(teamVM)); }
public void TestExport_TemplateSelected_Overwrite() { // Arrange TeamVM team = PrepareExport(); using (var stream = File.AppendText(tempFile)) { stream.WriteLine("FOO"); } // Act templatesController.ViewModel.ExportCommand.Execute(); var exportedTeam = Serializer.Instance.Load <DummyTeam> (tempFile); // Assert Assert.AreEqual(team.Model, exportedTeam); }
public ActionResult Create(TeamVM model) { try { if (ModelState.IsValid) { model.Name = model.Name.Replace(" ", ""); var teamId = _teamManager.SaveTeam(model); return(Json(new { Status = "Success" })); } return(View(model)); } catch (Exception ex) { } return(Json(new { Status = "Error" })); }
public void TestExport_TemplateSelected_NotOverwrite() { // Arrange TeamVM team = PrepareExport(); using (var stream = File.AppendText(tempFile)) { stream.WriteLine("FOO"); } mockDialogs.Setup(m => m.QuestionMessage(It.IsAny <string> (), null, It.IsAny <DummyTemplatesController> ())). Returns(AsyncHelpers.Return(false)); templatesController.ViewModel.ExportCommand.Execute(); // Assert Assert.IsTrue(File.Exists(tempFile)); Assert.Throws <JsonReaderException> (() => Serializer.Instance.Load <DummyTeam> (tempFile)); }
public ActionResult Index() { try { var team = repo.GetTeam(TeamID); var teamVM = new TeamVM { Name = team.Name, Id = team.ID }; var teamMembers = team.TeamMembers.OrderBy(s => s.Member.FirstName).ToList(); foreach (var member in teamMembers) { var memberVM = new MemberVM(); memberVM.Name = member.Member.FirstName; memberVM.EmailAddress = member.Member.EmailAddress; memberVM.AvatarHash = UserService.GetAvatarUrl(member.Member.Avatar, 30); memberVM.JoinedDate = member.CreatedDate.ToShortDateString(); if (member.Member.LastLoginDate.HasValue) { memberVM.LastLoginDate = member.Member.LastLoginDate.Value.ToString("g"); } teamVM.Members.Add(memberVM); } var membersNotJoinedList = repo.GetTeamMembersWhoHasntJoined(TeamID).OrderBy(s => s.EmailAddress).ToList(); foreach (var member in membersNotJoinedList) { var invitation = new MemberInvitation { EmailAddress = member.EmailAddress, DateInvited = member.CreatedDate.ToString("g") }; invitation.AvatarHash = UserService.GetImageSource(member.EmailAddress); teamVM.MembersInvited.Add(invitation); } return(View(teamVM)); } catch (Exception ex) { log.Error(ex); return(View("Error")); } }
public TeamVM PrepareExport() { Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam(); team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); templatesController.ViewModel.Selection.Add(teamVM); tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); tempFile = Path.ChangeExtension(tempFile, null); mockDialogs.Setup(m => m.SaveFile(It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string []> ())). Returns(tempFile); return(teamVM); }
void Add(TeamVM teamVM) { teamsStore.AppendValues (teamVM, teamVM.Editable); }
void Select(TeamVM teamVM) { TreeIter iter; teamsStore.GetIterFirst (out iter); while (teamsStore.IterIsValid (iter)) { if ((teamsStore.GetValue (iter, COL_TEAM) as TeamVM).Model.Equals (teamVM.Model)) { teamseditortreeview.Selection.SelectIter (iter); break; } teamsStore.IterNext (ref iter); } }
void Remove(TeamVM teamVM) { TreeIter iter; teamsStore.GetIterFirst (out iter); while (teamsStore.IterIsValid (iter)) { if (teamsStore.GetValue (iter, COL_TEAM) == teamVM) { teamsStore.Remove (ref iter); break; } teamsStore.IterNext (ref iter); } }