Ejemplo n.º 1
0
 private RankingEntry EntryFromClub(Club c)
 {
     foreach (RankingEntry entry in entries)
         if (entry.Club == c)
             return entry;
     return null;
 }
Ejemplo n.º 2
0
        public IHttpActionResult PutClub(int id, Club club)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != club.Id)
            {
                return BadRequest();
            }


            try
            {
                _ClubService.Update(club);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClubExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 3
0
    public static List<Club> getClubs()
    {
        List<Club> categoryList = new List<Club>();
        //SqlConnection connection = new SqlConnection(GetConnectionString());
        SqlConnection connection = new SqlConnection(ConnectStringGenerator.getConnectString());
        string sel = "execute usp_selectClub";
        SqlCommand cmd = new SqlCommand(sel, connection);
        connection.Open();
        SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
        Club club;

        while (dr.Read())
        {

            club = new Club();
            club.ClubID = dr["ClubID"].ToString();
            club.OrgID = dr["OrgID"].ToString();
            club.ClubDescription = dr["ClubDescription"].ToString();
            categoryList.Add(club);
            /*
            //course.CategoryID = dr["ICategoryID"].ToString();
            //course.ShortName = dr["IShortName"].ToString();
            //course.LongName = dr["LongName"].ToString();
            categoryList.Add(Faculty);
             */
        }
        dr.Close();
        return categoryList;
    }
Ejemplo n.º 4
0
        public ActionResult Create(ClubCreateViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.ExistingClubs = FindExistingClubs();
                return RedirectToAction("Create", "ExternalTeam", new { vm.ReturnTo });
            }

            Club club = Context.Clubs.SingleOrDefault(c => c.Name == vm.Name);

            if (club != null)
            {
                TempData["message"] = "Club already exists";
                return RedirectToAction("Create", "ExternalTeam", new {vm.ReturnTo});
            }

            var newClub = new Club
            {
                Name = vm.Name,
                CityState = vm.CityState
            };

            Context.Clubs.Add(newClub);

            Context.SaveChanges();

            return RedirectToAction("Create", "ExternalTeam", new { vm.ReturnTo });
        }
Ejemplo n.º 5
0
        //internal static string SavePic(HttpPostedFile file)
        //{
        //    FileInfo fi = new FileInfo(file.FileName);
        //    string fileName = string.Format("{0}{1}", Guid.NewGuid().ToString(), fi.Extension);
        //    string fullPath = Path.Combine(ConfigGlobal.ClubLogoPath, fileName);
        //    file.SaveAs(fullPath);
        //    return fileName;
        //}
        public static void ApplyClub(string fullName, string shortName, string slogan, string desc, int creatorUid,
            string creatorUserName)
        {
            var club = new Club();
            club.FullName = fullName;
            club.ShortName = shortName;
            club.Slogan = slogan;
            club.LogoName = ConfigGlobal.DefaultClubLogoName;
            club.RankLevel = ConfigGlobal.ClubDefaultRankLevel;
            club.RankScore = 0;
            club.Description = desc;
            club.CreatorUid = creatorUid;
            club.CreatorUserName = creatorUserName;
            club.ManagerUid = creatorUid;
            club.ManagerUserName = creatorUserName;
            club.CreateDate = DateTime.Now;
            club.UpdateDate = DateTime.Now;
            club.Fortune = 0;
            club.MemberCredit = 0;
            club.MemberFortune = 0;
            club.MemberLoyalty = 0;

            InsertClub(club);

            club = GetClubInfo(fullName);
            if (club != null)
            {
                ClubSysPrivateMessage.SendMessage(club.ID.Value, creatorUserName, ClubSysMessageType.ApplyClub);
            }
        }
Ejemplo n.º 6
0
 public void deleteAClub(Club c)
 {
     String myQuery = "delete from club where code = '" + c.Code + "'";
     MySqlCommand myCommand = new MySqlCommand(myQuery);
     myCommand.Connection = conn;
     myCommand.ExecuteNonQuery();
 }
Ejemplo n.º 7
0
        public Club getAClubById(string id)
        {
            Club c = null;
            string requete = "select * from club where code = '"+id+"'";

            MySqlCommand cmd = new MySqlCommand(requete, conn);
            MySqlDataReader rdr = cmd.ExecuteReader();

            if (rdr.Read())
            {
                c = new Club();
                c.Code = rdr[0].ToString();
                c.Nom = rdr[1].ToString();
                c.Rue = rdr[2].ToString();
                c.Cp = rdr[3].ToString();
                c.Ville = rdr[4].ToString();
                c.Gps_lat = Convert.ToDouble(rdr[5].ToString());
                c.Gps_lon = Convert.ToDouble(rdr[6].ToString());
                c.Tel = rdr[7].ToString();
                c.Email = rdr[8].ToString();
                c.Licencie = Convert.ToInt16(rdr[9].ToString());
            }
            rdr.Close();
            return c;
        }
Ejemplo n.º 8
0
        public List<Club> getAllClubs()
        {
            List<Club> lesClubsRecuperes = new List<Club>();

            string requete = "select * from club";

            MySqlCommand cmd = new MySqlCommand(requete, conn);
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                Club c = new Club();
                c.Code = rdr[0].ToString();
                c.Nom = rdr[1].ToString();
                c.Rue = rdr[2].ToString();
                c.Cp = rdr[3].ToString();
                c.Ville = rdr[4].ToString();
                c.Gps_lat = Convert.ToDouble(rdr[5].ToString());
                c.Gps_lon = Convert.ToDouble(rdr[6].ToString());
                c.Tel = rdr[7].ToString();
                c.Email = rdr[8].ToString();
                c.Licencie = Convert.ToInt16(rdr[9].ToString());

                DAOTrou daot = new DAOTrou();
                c.setLesTrous(daot.getAllTrousFromClub(c));

                lesClubsRecuperes.Add(c);
            }
            rdr.Close();
            return lesClubsRecuperes;
        }
Ejemplo n.º 9
0
 public Ranking(PointSystem system, Club [] clubs)
 {
     this.system = system;
     this.entries=new RankingEntry[clubs.Length];
     for(int i=0; i<clubs.Length; i++)
         this.entries[i]=new RankingEntry(clubs[i], system.InitialPoints);
 }
Ejemplo n.º 10
0
 public void Leave(Club club)
 {
     if (memberIn.Contains(club))
     {
         memberIn.Remove(club);
         club.RemoveMember(this);
     }
 }
Ejemplo n.º 11
0
        public void JoinClub()
        {
            var p = new Person("test", "test", USA);
            var theClub = new Club();
            p.Join(theClub);

            assertIsConsistent(p, theClub);
        }
Ejemplo n.º 12
0
        public void AddMember()
        {
            var p = new Person("test", "test", USA);
            var theClub = new Club();
            theClub.AddMember(p);

            assertIsConsistent(p, theClub);
        }
Ejemplo n.º 13
0
 public void Join(Club club)
 {
     if (!memberIn.Contains(club))
     {
         memberIn.Add(club);
         club.AddMember(this);
     }
 }
        public FrmReportEmailSend(Match match, Club homeClub, Team homeTeam, Club guestClub, Team guestTeam)
        {
            InitializeComponent();

            txtSubject.Text = "Utakmica br. " + match.MatchId + ": " + homeClub.Name + " - " + guestClub.Name;
            txtMailBody.Text = "Rezultat utakmice br. " + match.MatchId + ": \n" +
                homeClub.Name + " - " + guestClub.Name + " " + homeTeam.Goals + ":" + guestTeam.Goals;
            txtRemarks.Text = "";
        }
 public void FrenchLeague1PointSystem_PointTotalConstructorTest()
 {
     Club leClub = new Club("France");
     Match match = new Match(leClub,"home"); // TODO: initialisez à une valeur appropriée
     bool home = true;
     FrenchLeague1PointSystem.PointTotal target = new FrenchLeague1PointSystem.PointTotal(match, home);
     Assert.ReferenceEquals(target, "France");
     Assert.ReferenceEquals(target, home);
 }
Ejemplo n.º 16
0
partial         void UpdateClub(Club actual)
        {
            int cant = this.ExecuteCommand(
                "UPDATE Club SET Nombre={1}, Ciudad={2} WHERE Codigo = {0}",
                actual.Codigo,
                actual.Nombre,
                actual.Ciudad);
            if (cant < 1)
                throw new Exception("Error al actualizar club");
        }
 private static Club GetClub(ImporterResultRowsAggregated aggregatedRow)
 {
     var club = new Club();
     club.Url = aggregatedRow.GetUrl();
     club.Email = aggregatedRow.GetEmail();
     club.Location = aggregatedRow.GetLocation();
     club.AreaOfWork = aggregatedRow.GetTaetigkeitsfeld();
     club.Name = aggregatedRow.GetName();
     return club;
 }
Ejemplo n.º 18
0
	void Start(){
		// 2 - Movement

		currentClub = clubs[currentClubIndex];
		clubTitle.text = "Club: " + currentClub.title + "transform:  " + currentClub.transformX;
		view = "shot";

		yardsToPin.x = (pin.position.x - ball.position.x) * 2;
		yardsToPinText.text = "Yards to Pin: " + yardsToPin.x;
	}
Ejemplo n.º 19
0
        public IHttpActionResult PostClub(Club club)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            _ClubService.Create(club);

            return CreatedAtRoute("DefaultApi", new { id = club.Id }, club);
        }
Ejemplo n.º 20
0
	// Use this for initialization
	void Start () {
		instance = this;
		ballMoving = false;
		ballFired = false;
		ballForce = 0f;
		forcing = false;
		gameOver = false;
		score = INITIAL_SCORE;
		pos = transform.localPosition;
		initialY = pos.y;
	}
        public void ShouldValidateAllItemsInEnumeration()
        {
            var member1 = new Member(null);
            var member2 = new Member(null);
            var club = new Club(new Member("president"), member1, member2);
            var report = new ValidationReport();
            _en1.Validate(club, report, ValidationReportDepth.FieldShortCircuit);

            var memberNameExp = new EquatableExpression(ExpressionHelper.New<Member, string>(mm => mm.Name));
            Assert.IsTrue(report.HasError(member1, memberNameExp), "Expected validation failure for member1. Name was null...");
            Assert.IsTrue(report.HasError(member2, memberNameExp), "Expected validation failure for member2. Name was null...");
        }
Ejemplo n.º 22
0
        public void LeaveClub()
        {
            var p1 = new Person("test", "test", USA);
            var p2 = new Person("test", "test", USA);
            var theClub = new Club();
            theClub.AddMember(p1);
            theClub.AddMember(p2);
            p1.Leave(theClub);

            assertIsConsistent(p2, theClub);
            Assert.AreEqual(0, p1.MemberOf.Count());
            Assert.AreEqual(1, theClub.Members.Count());
        }
Ejemplo n.º 23
0
 public void ShouldBeClubNameDashTeamName()
 {
     var club = new Club
                    {
                        Name = ClubName
                    };
     var sut = new ExternalTeam
                   {
                       Club = club,
                       Name = TeamName
                   };
     Assert.AreEqual("ClubName - TeamName", sut.FullName);
 }
Ejemplo n.º 24
0
        public static ClubModel MapClub(Club club)
        {
            ClubModel clubModel = new ClubModel()
            {
                Id = club.Id,
                Image = club.Image,
                Name = club.Name,
                ShortName = club.ShortName,
                Description = club.Description,
                Settings = JsonConvert.DeserializeObject<ClubSettingsModel>(club.Settings)
            };

            return clubModel;
        }
Ejemplo n.º 25
0
        public void MulitpleClubs()
        {
            var p1 = new Person("test", "test", USA);
            var p2 = new Person("test", "test", USA);
            var club1 = new Club();
            var club2 = new Club();
            p1.Join(club1);
            p1.Join(club2);
            club1.AddMember(p2);
            club2.AddMember(p2);

            assertIsConsistent(p1, club1);
            assertIsConsistent(p1, club2);
            assertIsConsistent(p2, club1);
            assertIsConsistent(p1, club2);
        }
Ejemplo n.º 26
0
        public static IClub ConstructClubFromDAO(List<object> clubFromDao)
        {
            if (clubFromDao == null)
                return null;

            IClub result = new Club();

            IManageTeamDatabase manageTeamDatabase = DatabaseSingleton<ManageTeamDatabase>.Instance;

            // [0] => ID, [1] => Name
            result.Id = (int)clubFromDao[0];
            result.Name = (string)clubFromDao[1];
            result.Teams = DaoServicesTeam.ConstructTeamsFromDAO(manageTeamDatabase.GetTeams(result.Id));

            return result;
        }
Ejemplo n.º 27
0
        public void WriteAndReadClub()
        {
            var tempName = Guid.NewGuid().ToString();
            using (var databaseSession = NHibernateHelper.OpenSession())
            {
                var clubs = from club in databaseSession.Query<Club>()
                            where club.Name == tempName
                            select club;

                Assert.IsNotNull(clubs);
                Assert.AreEqual(0, clubs.Count());

                var clubToAdd = new Club { Name = tempName, ClubId = "1234", Country = "SE" };
                using (var transaction = databaseSession.BeginTransaction())
                {
                    databaseSession.Save(clubToAdd);
                    transaction.Commit();
                }
            }

            using (var databaseSession = NHibernateHelper.OpenSession())
            {
                var clubs = from club in databaseSession.Query<Club>()
                            where club.Name == tempName
                            select club;

                Assert.IsNotNull(clubs);
                Assert.AreEqual(1, clubs.Count());

                using (var transaction = databaseSession.BeginTransaction())
                {
                    databaseSession.Delete(clubs.ToArray()[0]);
                    transaction.Commit();
                }
            }

            using (var databaseSession = NHibernateHelper.OpenSession())
            {
                var clubs = from club in databaseSession.Query<Club>()
                            where club.Name == tempName
                            select club;

                Assert.IsNotNull(clubs);
                Assert.AreEqual(0, clubs.Count());
            }
        }
Ejemplo n.º 28
0
        public FrmMatchReport(Match match, Club homeClub, Club guestClub, Team homeTeam, Team guestTeam,
            BindingList<TeamPlayer> homeTeamPlayers, BindingList<TeamPlayer> guestTeamPlayers,
            BindingList<TeamOfficial> homeTeamOfficials, BindingList<TeamOfficial> guestTeamOfficials, string refereePairName)
        {
            InitializeComponent();

            this.Match = match;
            this.HomeClub = homeClub;
            this.GuestClub = guestClub;
            this.HomeTeam = homeTeam;
            this.GuestTeam = guestTeam;
            this.refereePairName = refereePairName;
            this.HomeTeamPlayers = homeTeamPlayers;
            this.GuestTeamPlayers = guestTeamPlayers;
            this.HomeTeamOfficials = homeTeamOfficials;
            this.GuestTeamOfficials = guestTeamOfficials;
        }
Ejemplo n.º 29
0
    public Club GetClubByID(int clubid)
    {
        IDataReader resultSet;

        try
        {
            myDatabase.Open(myConnectionString);

            String sqlText = String.Format(
                @"SELECT clubName, city, clubid, email
                FROM Club
                WHERE clubid = {0}", clubid);

            resultSet = myDatabase.ExecuteQuery(sqlText);

            if (resultSet.Read() == true)
            {
                Club club = new Club();

                club.ClubId = (int)resultSet["clubid"];
                club.ClubName = (String)resultSet["clubName"];
                club.ClubCity = (String)resultSet["city"];
                club.ClubEmail = (String)resultSet["email"];

                return club;
            }

            else
            {
                return null;
            }
        }
            catch (Exception)
            {
                return null;
            }

            finally
        {
            myDatabase.Close();
        }
    
    }
        public static void RunObjectGraphValidation(Club club)
        {
            Engine engine = new Engine();

            engine.For<Member>()
                .Setup(member => member.Name)
                    .MustNotBeNullOrEmpty()
                .Setup(member => member.Email)
                    .MustNotBeNullOrEmpty();

            engine.For<Club>()
                .Setup(c => club.President)
                    .MustNotBeNull()
                    .CallValidate() //Calls engine.Validate for the President.
                .Setup(c => club.Members)
                    .MustNotBeNull()
                    .CallValidateForEachElement(); //Calls engine.Validate() on each element

            club.IsValid = engine.Validate(club).ToString();
        }
Ejemplo n.º 31
0
        public System.IO.Stream CreateAgenda(AgendaConfig config, Club club, Meeting meeting)
        {
            string speech2Title       = string.Empty;
            string speech2SpeakerName = string.Empty;
            string speech2SpeechType  = string.Empty;
            string evaluator2Name     = string.Empty;

            bool   useMentorTime     = !string.IsNullOrWhiteSpace(meeting.MentorName);
            string mentorItemStyle   = "AgendaItem";
            string mentorDetailStyle = "AgendaDetails";
            int    mentorTimeToUse   = config.MentorMinutes;

            if (!useMentorTime)
            {
                mentorTimeToUse   = 0;
                mentorItemStyle   = "InactiveDetails";
                mentorDetailStyle = "InactiveDetails";
            }


            var    twoSpeeches            = (meeting.Speech2 != null);
            string speakerIntroduction    = "Toastmaster Introduces Speaker";
            string evaluationIntroduction = "Toastmaster Introduces Evaluator (2-3 minutes)";
            string speech2Style           = "InactiveDetails";
            int    speechMinutes          = meeting.Speech1.MaxLengthMinutes + config.EvaluationTimeMinutes;
            int    evaluationMinutes      = config.EvaluationTimeMinutes;

            if (twoSpeeches)
            {
                speakerIntroduction    = "Toastmaster Introduces Speakers";
                evaluationIntroduction = "Toastmaster Introduces Evaluators (2-3 min ea)";
                speech2Style           = "AgendaDetails";
                speechMinutes         += meeting.Speech2.MaxLengthMinutes + config.EvaluationTimeMinutes;
                speech2Title           = meeting.Speech2.Title;
                speech2SpeakerName     = meeting.Speech2.SpeakerName;
                speech2SpeechType      = meeting.Speech2.SpeechType;
                evaluator2Name         = meeting.Speech2.EvaluatorName;
                evaluationMinutes     += config.EvaluationTimeMinutes;
            }

            int backendMinutes = config.MinClubBusinessMinutes +
                                 mentorTimeToUse + config.ListenerMinutes +
                                 config.FunctionaryReportMinutes + evaluationMinutes;

            DateTime start = meeting.MeetingStartDateTime;
            DateTime end   = meeting.MeetingEndDateTime;
            DateTime toastmasterTakeover = start.AddMinutes(config.PresidingOfficerIntroMinutes);
            DateTime speech1             = toastmasterTakeover.AddMinutes(config.ToastmasterIntroMinutes);
            DateTime tableTopics         = speech1.AddMinutes(speechMinutes);

            DateTime minBackend     = meeting.MeetingEndDateTime.AddMinutes(-backendMinutes);
            DateTime minTableTopics = tableTopics.AddMinutes(config.MinTableTopicsMinutes);
            DateTime maxTableTopics = tableTopics.AddMinutes(config.MaxTableTopicsMinutes);

            DateTime evaluations = DetermineTableTopicsEnd(minBackend, minTableTopics, maxTableTopics);
            DateTime funcReports = evaluations.AddMinutes(evaluationMinutes);
            DateTime listener    = funcReports.AddMinutes(config.FunctionaryReportMinutes);
            DateTime mentor      = listener.AddMinutes(config.ListenerMinutes);
            DateTime poReturn    = mentor.AddMinutes(mentorTimeToUse);

            string meetingDate             = start.ToString(config.MeetingDateFormat);
            string meetingStartTime        = start.ToString(config.MeetingTimeFormat);
            string meetingEndTime          = end.ToString(config.MeetingTimeFormat);
            string agendaStartTime         = start.ToString(config.AgendaTimeFormat);
            string toastmasterTakeoverTime = toastmasterTakeover.ToString(config.AgendaTimeFormat);
            string speech1Time             = speech1.ToString(config.AgendaTimeFormat);
            string tableTopicsTime         = tableTopics.ToString(config.AgendaTimeFormat);
            string evalTime       = evaluations.ToString(config.AgendaTimeFormat);
            string funcReportTime = funcReports.ToString(config.AgendaTimeFormat);
            string listenerTime   = listener.ToString(config.AgendaTimeFormat);
            string mentorTime     = mentor.ToString(config.AgendaTimeFormat);
            string poReturnTime   = poReturn.ToString(config.AgendaTimeFormat);

            var agenda = _htmlTemplate
                         .ReplaceField("{BannerImage}", _bannerImage)
                         .ReplaceField("{BannerContentType}", _bannerContentType)
                         .ReplaceField("{ClubName}", club.Name)
                         .ReplaceField("{PresidentName}", club.Officers.PresidentName)
                         .ReplaceField("{VPEName}", club.Officers.VPEducationName)
                         .ReplaceField("{VPMName}", club.Officers.VPMembershipName)
                         .ReplaceField("{VPPRName}", club.Officers.VPPublicRelationsName)
                         .ReplaceField("{SecName}", club.Officers.SecretaryName)
                         .ReplaceField("{TreasName}", club.Officers.TreasurerName)
                         .ReplaceField("{SEAName}", club.Officers.SeargeantAtArmsName)
                         .ReplaceField("{MeetingMessage}", club.MeetingMessage)
                         .ReplaceField("{WebsiteUrl}", club.WebsiteUrl)
                         .ReplaceField("{EmailUrl}", club.EmailAddress)
                         .ReplaceAddress("{WebsiteAddress}", club.WebsiteUrl)
                         .ReplaceAddress("{EmailAddress}", club.EmailAddress)
                         .ReplaceField("{SlackChannel}", club.SlackChannel)
                         .ReplaceField("{ClubMissionStatement}", club.MissionStatement)
                         .ReplaceField("{ClubNumber}", club.Number)
                         .ReplaceField("{MeetingDate}", meetingDate)
                         .ReplaceField("{MeetingStartTime}", meetingStartTime)
                         .ReplaceField("{AgendaStartTime}", agendaStartTime)
                         .ReplaceField("{Speech1Time}", speech1Time)
                         .ReplaceField("{ToastmasterTakeoverTime}", toastmasterTakeoverTime)
                         .ReplaceField("{TableTopicsTime}", tableTopicsTime)
                         .ReplaceField("{MeetingEndTime}", meetingEndTime)
                         .ReplaceField("{POName}", meeting.PresidingOfficerName)
                         .ReplaceField("{TMName}", meeting.ToastmasterName)
                         .ReplaceField("{AhCounterName}", meeting.AhCounterName)
                         .ReplaceField("{GrammarianName}", meeting.GrammarianName)
                         .ReplaceField("{TimerName}", meeting.TimerName)
                         .ReplaceField("{GeneralEvaluatorName}", meeting.GeneralEvaluatorName)
                         .ReplaceField("{ListenerName}", meeting.ListenerName)
                         .ReplaceField("{MeetingTheme}", meeting.Theme)
                         .ReplaceField("{WordOfTheDay}", meeting.WordOfTheDay)
                         .ReplaceField("{Speech1Title}", meeting.Speech1.Title)
                         .ReplaceField("{Speaker1Name}", meeting.Speech1.SpeakerName)
                         .ReplaceField("{Speech1Type}", meeting.Speech1.SpeechType)
                         .ReplaceField("{Speech2Style}", speech2Style)
                         .ReplaceField("{Speech2Title}", speech2Title)
                         .ReplaceField("{Speaker2Name}", speech2SpeakerName)
                         .ReplaceField("{Speech2Type}", speech2SpeechType)
                         .ReplaceField("{SpeakerIntroduction}", speakerIntroduction)
                         .ReplaceField("{TableTopicsMaster}", meeting.TopicMasterName)
                         .ReplaceField("{EvaluationMinutes}", config.EvaluationTimeMinutes.ToString())
                         .ReplaceField("{EvaluationIntroduction}", evaluationIntroduction)
                         .ReplaceField("{EvaluationTime}", evalTime)
                         .ReplaceField("{Evaluator1Name}", meeting.Speech1.EvaluatorName)
                         .ReplaceField("{Evaluator2Name}", evaluator2Name)
                         .ReplaceField("{FunctionaryReportTime}", funcReportTime)
                         .ReplaceField("{ListenerTime}", listenerTime)
                         .ReplaceField("{MentorItemStyle}", mentorItemStyle)
                         .ReplaceField("{MentorDetailsStyle}", mentorDetailStyle)
                         .ReplaceField("{MentorTime}", mentorTime)
                         .ReplaceField("{MentorName}", meeting.MentorName)
                         .ReplaceField("{POReturnTime}", poReturnTime);

            byte[]       byteArray = Encoding.ASCII.GetBytes(agenda);
            MemoryStream stream    = new MemoryStream(byteArray);

            return(stream);
        }
Ejemplo n.º 32
0
 public void AddClub(Club club)
 {
     clubList.Add(club.Id, club);
 }
Ejemplo n.º 33
0
 public IActionResult AddClub([FromBody] Club json)
 {
     DB.Clubs.Add(json);
     DB.SaveChanges();
     return(GetClubs());
 }
Ejemplo n.º 34
0
        //
        // GET: /Club/Details/5
        public ViewResult Details(int id)
        {
            Club club = db.Clubs.Find(id);

            return(View(club));
        }
Ejemplo n.º 35
0
 public ActionResult Edit(Club club)
 {
     _db.Entry(club).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 36
0
 public ActionResult ClubAdd(Club club)
 {
     clubRepository.Insert(club);
     return(RedirectToAction("ClubList", "Home"));
 }
Ejemplo n.º 37
0
 public static void SaveClub(Club club)
 {
     ClubDAL.SaveClub(club);
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Removes a club
 /// </summary>
 /// <param name="clubIn"></param>
 /// <returns></returns>
 public async Task RemoveAsync(Club clubIn)
 {
     await this.clubs.DeleteOneAsync(club => club.Id == clubIn.Id);
 }
Ejemplo n.º 39
0
 public IActionResult Create(Club c)
 {
     //FakeClubRepository.AddClub(c);
     repository.AddClub(c);
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 40
0
        private void SeedAdminMember(ClubContext clubc, UserManager <ApplicationUser> manager, ApplicationDbContext context, Club club)
        {
            PasswordHasher ps           = new PasswordHasher();
            Member         chosenMember = club.clubMembers.FirstOrDefault();

            if (chosenMember == null)
            {
                throw new Exception("No Club Member available for " + club.ClubName);
            }
            else
            {
                club.adminID = chosenMember.MemberID;
            }
            clubc.SaveChanges();
            // Add the membership and role for this member
            if (chosenMember != null)
            {
                context.Users.AddOrUpdate(u => u.UserName,
                                          new ApplicationUser
                {
                    ClubEntityID   = chosenMember.StudentID,
                    FirstName      = chosenMember.studentMember.FirstName,
                    Surname        = chosenMember.studentMember.SecondName,
                    Email          = chosenMember.StudentID + "@mail.itsligo.ie",
                    UserName       = chosenMember.StudentID + "@mail.itsligo.ie",
                    EmailConfirmed = true,
                    JoinDate       = DateTime.Now,
                    SecurityStamp  = Guid.NewGuid().ToString(),
                    PasswordHash   = ps.HashPassword(chosenMember.StudentID + "s$1")
                });
            }
            context.SaveChanges();
            ApplicationUser ChosenClubAdmin = manager.FindByEmail(chosenMember.StudentID + "@mail.itsligo.ie");

            if (ChosenClubAdmin != null)
            {
                manager.AddToRoles(ChosenClubAdmin.Id, new string[] { "ClubAdmin" });
            }
            context.SaveChanges();
        }
Ejemplo n.º 41
0
 public AvailabilityApiController(Club club, IAvailabilityQuery availabilityQuery)
 {
     this.club = club;
     this.availabilityQuery = availabilityQuery;
 }
Ejemplo n.º 42
0
        public override void Full(StackPanel spRanking)
        {
            spRanking.Children.Clear();

            int i = 0;

            List <Club> clubs = _round.Ranking(_rankingType);

            //If we choose to focus on a team, we center the ranking on the team and +-2 other teams around
            int indexTeam = -1;

            if (_focusOnTeam && _team != null)
            {
                clubs = new List <Club>();
                List <Club> ranking = _round.Ranking();
                int         index   = ranking.IndexOf(Session.Instance.Game.club);
                index = index - 2;
                if (index < 0)
                {
                    index = 0;
                }
                if (index > ranking.Count - 5)
                {
                    index = ranking.Count - 5;
                }
                i = index;
                for (int j = index; j < index + 5; j++)
                {
                    Club c = ranking[j];
                    clubs.Add(c);
                    if (c == Session.Instance.Game.club)
                    {
                        indexTeam = j - index;
                    }
                }
            }

            double fontSize         = (double)Application.Current.FindResource("TailleMoyenne");
            double regularCellWidth = 36 * _sizeMultiplier;

            StackPanel spTitle = new StackPanel();

            spTitle.Orientation = Orientation.Horizontal;
            spTitle.Children.Add(ViewUtils.CreateLabel("", "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth / 1.25 + regularCellWidth / 1.5 + regularCellWidth * 3.5));
            spTitle.Children.Add(ViewUtils.CreateLabel("Pts", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth));
            spTitle.Children.Add(ViewUtils.CreateLabel("J", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth));
            if (!_reduced)
            {
                spTitle.Children.Add(ViewUtils.CreateLabel("G", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth));
                spTitle.Children.Add(ViewUtils.CreateLabel("N", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth));
                spTitle.Children.Add(ViewUtils.CreateLabel("P", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth));
                spTitle.Children.Add(ViewUtils.CreateLabel("p.", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth));
                spTitle.Children.Add(ViewUtils.CreateLabel("c.", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth));
            }
            spTitle.Children.Add(ViewUtils.CreateLabel("Diff", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth * 1.25));
            spRanking.Children.Add(spTitle);

            foreach (Club c in clubs)
            {
                i++;
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;


                sp.Children.Add(ViewUtils.CreateLabel(i.ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth / 1.25));


                if (_round.Tournament.IsInternational() && (c as CityClub) != null)
                {
                    sp.Children.Add(ViewUtils.CreateFlag((c as CityClub).city.Country(), regularCellWidth / 1.5, regularCellWidth / 1.5));
                }
                else if (_round.Tournament.IsInternational() && (c as ReserveClub) != null)
                {
                    sp.Children.Add(ViewUtils.CreateFlag((c as ReserveClub).FannionClub.city.Country(), regularCellWidth / 1.5, regularCellWidth / 1.5));
                }
                else
                {
                    sp.Children.Add(ViewUtils.CreateLogo(c, regularCellWidth / 1.5, regularCellWidth / 1.5));
                }

                sp.Children.Add(ViewUtils.CreateLabelOpenWindow <Club>(c, OpenClub, _round.Tournament.isChampionship ? c.extendedName : c.shortName, "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth * 3.5));
                sp.Children.Add(ViewUtils.CreateLabel(_round.Points(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth, null, null, true));
                sp.Children.Add(ViewUtils.CreateLabel(_round.Played(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth));
                if (!_reduced)
                {
                    sp.Children.Add(ViewUtils.CreateLabel(_round.Wins(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth));
                    sp.Children.Add(ViewUtils.CreateLabel(_round.Draws(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth));
                    sp.Children.Add(ViewUtils.CreateLabel(_round.Loses(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth));
                    sp.Children.Add(ViewUtils.CreateLabel(_round.GoalsFor(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth));
                    sp.Children.Add(ViewUtils.CreateLabel(_round.GoalsAgainst(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth));
                }
                sp.Children.Add(ViewUtils.CreateLabel(_round.Difference(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth * 1.25));

                spRanking.Children.Add(sp);
            }

            //Only show colors when the ranking is not focused on a team
            if (!_focusOnTeam)
            {
                Club          cupWinner       = (Session.Instance.Game.kernel.LocalisationTournament(_round.Tournament) as Country)?.Cup(1)?.Winner();
                int           roundLevel      = _round.Tournament.level;
                ILocalisation localisation    = Session.Instance.Game.kernel.LocalisationTournament(_round.Tournament);
                Country       country         = localisation as Country;
                List <Club>   registeredClubs = new List <Club>();
                if (country != null && roundLevel == 1)
                {
                    Continent continent      = country.Continent;
                    int       nationIndex    = continent.associationRanking.IndexOf(country) + 1;
                    int       currentRanking = 0;
                    int       totalQualificationsFromLeague = (from qualification in continent.continentalQualifications where (qualification.ranking == nationIndex && !qualification.isNextYear) select qualification.qualifies).Sum();

                    foreach (Qualification q in continent.continentalQualifications)
                    {
                        //q.isNextYear refeer to cup winner qualification for continental competition
                        if (q.ranking == nationIndex && (!q.isNextYear || registeredClubs.Contains(cupWinner)))
                        {
                            for (int j = 0; j < q.qualifies; j++)
                            {
                                registeredClubs.Add(clubs[currentRanking]);
                                string          color     = QualificationColor(q);
                                SolidColorBrush lineColor = Application.Current.TryFindResource(color) as SolidColorBrush;
                                (spRanking.Children[currentRanking + 1] as StackPanel).Background = lineColor;
                                currentRanking++;
                            }
                        }
                        else if (q.ranking == nationIndex && q.isNextYear && clubs.Contains(cupWinner))
                        {
                            string          color     = QualificationColor(q);
                            SolidColorBrush lineColor = Application.Current.TryFindResource(color) as SolidColorBrush;
                            (spRanking.Children[clubs.IndexOf(cupWinner) + 1] as StackPanel).Background = lineColor;
                        }
                    }
                }
                foreach (Qualification q in _round.qualifications)
                {
                    string color = "backgroundColor";
                    if (q.tournament.isChampionship)
                    {
                        if (q.tournament.level < roundLevel)
                        {
                            color = "promotionColor";
                        }
                        else if (q.tournament.level > roundLevel)
                        {
                            color = "relegationColor";
                        }
                        else if (q.tournament.level == roundLevel && q.roundId > _round.Tournament.rounds.IndexOf(_round))
                        {
                            color = "barrageColor";
                        }
                    }
                    else if (q.tournament.IsInternational())
                    {
                        if (q.tournament.level == 1 && q.tournament.rounds[q.roundId] as GroupsRound != null)
                        {
                            color = "cl1Color";
                        }
                        else if (q.tournament.level == 1)
                        {
                            color = "cl2Color";
                        }
                        else if (q.tournament.level == 2 && q.tournament.rounds[q.roundId] as GroupsRound != null)
                        {
                            color = "el1Color";
                        }
                        else if (q.tournament.level == 2)
                        {
                            color = "el2Color";
                        }
                        else if (q.tournament.level == 3)
                        {
                            color = "el3Color";
                        }
                    }
                    int index = q.ranking;
                    if (color != "backgroundColor" && clubs.Count > 0)
                    {
                        SolidColorBrush lineColor = Application.Current.TryFindResource(color) as SolidColorBrush;
                        (spRanking.Children[index] as StackPanel).Background = lineColor;
                    }
                }
            }
            else
            {
                SolidColorBrush color = new SolidColorBrush((System.Windows.Media.Color)Application.Current.TryFindResource("ColorDate"));
                color.Opacity = 0.6;
                (spRanking.Children[indexTeam + 1] as StackPanel).Background = color;
            }
        }
Ejemplo n.º 43
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="round"></param>
 /// <param name="sizeMultiplier">Width and font size multiplier</param>
 /// <param name="focusOnTeam">If true, only show 5 rows, focus the ranking around the team</param>
 /// <param name="team">The team to focus ranking on</param>
 public ViewRankingChampionship(ChampionshipRound round, double sizeMultiplier, bool focusOnTeam = false, Club team = null, bool reduced = false, RankingType rankingType = RankingType.General)
 {
     _round          = round;
     _sizeMultiplier = sizeMultiplier;
     _focusOnTeam    = focusOnTeam;
     _team           = team;
     _reduced        = reduced;
     _rankingType    = rankingType;
 }
Ejemplo n.º 44
0
 public void EditCommunity(string name, string description, uint?avatarId)
 {
     Club.EditClub(this.ClubId, name, this.m_clubInfo.shortName, description, avatarId, string.Empty);
 }
Ejemplo n.º 45
0
 public void CreateStream(string name, string subject, bool modsOnly)
 {
     Club.CreateStream(this.ClubId, name, subject, modsOnly);
 }
Ejemplo n.º 46
0
        public async Task ClubCreateReq2(GameSession session, ClubCreateReq2Message message)
        {
            var plr = session.Player;

            if (plr == null)
            {
                return;
            }

            var ascii = Config.Instance.Game.NickRestrictions.AsciiOnly;

            if (GameServer.Instance.ClubManager.Any(c =>
                                                    c.ClanName == message.Name || c.Players.ContainsKey(plr.Account.Id)) ||
                !Namecheck.IsNameValid(message.Name, true) ||
                ascii && message.Name.Any(c => c > 127) ||
                !ascii && message.Name.Any(c => c > 255))
            {
                Logger.ForAccount(plr).Information($"Couldnt create Clan : {message.Name}");
                await session.SendAsync(new ClubCreateAck2Message(1));
            }
            else
            {
                var clubDto = new ClubDto
                {
                    Name = message.Name,
                    Icon = ""
                };

                using (var db = GameDatabase.Open())
                {
                    try
                    {
                        using (var transaction = DbUtil.BeginTransaction(db))
                        {
                            await DbUtil.InsertAsync(db, clubDto,
                                                     statement => statement.AttachToTransaction(transaction));

                            var clubPlayerInfo = new ClubPlayerInfo
                            {
                                AccountId = session.Player.Account.Id,
                                Account   = session.Player.Account.AccountDto,
                                State     = ClubState.Joined,
                                Rank      = ClubRank.Master
                            };

                            var club = new Club(clubDto, new[] { clubPlayerInfo });
                            GameServer.Instance.ClubManager.Add(club);
                            transaction.Commit();

                            var clubplrdto = new ClubPlayerDto
                            {
                                PlayerId = (int)session.Player.Account.Id,
                                ClubId   = club.Id,
                                Rank     = (byte)ClubRank.Master,
                                State    = (int)ClubState.Joined
                            };
                            await DbUtil.InsertAsync(db, clubplrdto);

                            session.Player.Club = club;
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex.ToString());
                        await session.SendAsync(new ClubCreateAck2Message(1));

                        return;
                    }

                    await session.SendAsync(new ClubCreateAck2Message(0));

                    await session.SendAsync(new ClubMyInfoAckMessage(plr.Map <Player, ClubMyInfoDto>()));

                    Club.LogOn(plr);
                }
            }
        }
 public WindowFinance(string menu, Club club)
 {
     this.club = club;
     this.menu = menu + " >> " + Text.finance;
     finance   = club.finance;
 }
Ejemplo n.º 48
0
        public bool IsBuyable(UInt32 TypeID)
        {
            switch (GetItemGroup(TypeID))
            {
            case TITEMGROUP.ITEM_TYPE_BALL:
            {
                return(Ball.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_CLUB:
            {
                return(Club.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_CHARACTER:
            {
                return(Character.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_PART:
            {
                return(Part.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_HAIR_STYLE:
            {
                return(HairStyle.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_USE:
            {
                return(Items.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_CADDIE:
            {
                return(Caddie.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_CADDIE_ITEM:
            {
                return(CaddieItem.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_SETITEM:
            {
                return(SetITem.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_SKIN:
            {
                return(Skin.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_MASCOT:
            {
                return(Mascot.IsBuyable(TypeID));
            }

            case TITEMGROUP.ITEM_TYPE_CARD:
            {
                return(Card.IsBuyable(TypeID));
            }
            }
            return(false);
        }
Ejemplo n.º 49
0
 public ActionResult Create(Club club)
 {
     _db.Clubs.Add(club);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 50
0
        public Club verifAccountClub(Club c)

        {
            return(_club.Find(club => club.Email_Club == c.Email_Club || club.Nom_Club == c.Nom_Club && club.Nom_université == c.Nom_université && club.Nom_Ecole == c.Nom_Ecole).FirstOrDefault <Club>());
        }
 public ClubsManager()
 {
     Clubs  = new Club[100];
     Number = 0;
 }
Ejemplo n.º 52
0
        public MugdarWarchief() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
        {
            Name        = NameList.RandomName("orc");
            Body        = 0x190;
            BaseSoundID = 0x45A;
            Title       = "the Mugdar Clan War Chieftain";
            Hue         = Utility.RandomMinMax(2207, 2212);

            SetStr(96, 120);
            SetDex(450, 500);
            SetInt(36, 60);

            SetHits(1000, 1200);

            SetDamage(5, 7);

            SetDamageType(ResistanceType.Physical, 100);

            SetResistance(ResistanceType.Physical, 25, 30);
            SetResistance(ResistanceType.Fire, 20, 30);
            SetResistance(ResistanceType.Cold, 10, 20);
            SetResistance(ResistanceType.Poison, 10, 20);
            SetResistance(ResistanceType.Energy, 20, 30);

            SetSkill(SkillName.MagicResist, 50.1, 75.0);
            SetSkill(SkillName.Tactics, 55.1, 80.0);
            SetSkill(SkillName.Wrestling, 50.1, 70.0);

            Fame  = 0;
            Karma = 0;

            VirtualArmor = 28;

            BearMask helm = new BearMask();

            helm.Hue = 0;
            AddItem(helm);

            Club club = new Club();

            club.Hue = 0;
            AddItem(club);

            BoneLegs bonelegs = new BoneLegs();

            bonelegs.Hue = 0;
            AddItem(bonelegs);

            BoneChest bonechest = new BoneChest();

            bonechest.Hue = 0;
            AddItem(bonechest);

            BoneArms bonearms = new BoneArms();

            bonearms.Hue = 0;
            AddItem(bonearms);

            BoneGloves bonegloves = new BoneGloves();

            bonegloves.Hue = 0;
            AddItem(bonegloves);

            Sandals sandals = new Sandals();

            sandals.Hue = 0;
            AddItem(sandals);

            WoodenShield woodenshield = new WoodenShield();

            woodenshield.Hue = 0;
            AddItem(woodenshield);
        }
Ejemplo n.º 53
0
        /// <summary>
        /// Method parameters allows for UnitTesting
        /// </summary>
        /// <param name="context"></param>
        /// <param name="routeData"></param>
        /// <returns></returns>
        public static Club GetCurrentClub(HttpContextBase context, RouteData routeData)
        {
            // Fetch from URL
            var urlClubFilter = routeData.Values["club"] as string;

            // If in the direct access we can be dealing with /{ClubId}
            if (urlClubFilter == null && context.Request.Url != null)
            {
                var absolutePath = context.Request.Url.AbsolutePath;
                // Handle switching between one club to another
                if (absolutePath == "/Club/SetCurrentClub" && context.Request.UrlReferrer != null)
                {
                    urlClubFilter = context.Request.UrlReferrer.AbsolutePath.Split('/').FirstOrDefault(d => !string.IsNullOrWhiteSpace(d));
                    urlClubFilter = context.Server.UrlDecode(urlClubFilter);
                }
            }

            // Return Session Cache if set
            if (context.Items["CurrentClub"] != null)
            {
                var ghostClubSession = context.Items["CurrentClub"] as Club;
                if (ghostClubSession != null && Equals(ghostClubSession.ShortName, urlClubFilter))
                {
                    return(ghostClubSession);
                }
            }

            // Read Url
            if (urlClubFilter != null && !string.IsNullOrWhiteSpace(urlClubFilter))
            {
                Club ghost = new Club();
                using (var shortDb = new FlightContext())
                {
                    var club = shortDb.Clubs.SingleOrDefault(d => d.ShortName == urlClubFilter);
                    if (club != null)
                    {
                        ghost                    = new Club();
                        ghost.LocationId         = club.LocationId;
                        ghost.Location           = club.Location; // for allowing country
                        ghost.ContactInformation = club.ContactInformation;
                        ghost.ShortName          = club.ShortName;
                        ghost.Name               = club.Name;
                        if (club.Website != null && (club.Website.StartsWith("http://") || club.Website.StartsWith("https://")))
                        {
                            ghost.Website = club.Website;
                        }
                        else if (club.Website != null)
                        {
                            ghost.Website = "http://" + club.Website;
                        }
                        ghost.ClubId = club.ClubId;
                    }
                }

                // Set Session Cache
                context.Items.Remove("CurrentClub");
                context.Items.Add("CurrentClub", ghost);

                // Return Current Club
                return(ghost);
            }
            return(new Club());
        }
Ejemplo n.º 54
0
 public bool CanLeaveClub()
 {
     return(Club.GetMemberInfoForSelf(this.ClubId).Value.role != 1);
 }
Ejemplo n.º 55
0
 public void RemoveClub(Club club)
 {
     clubList.Remove(club.Id);
 }
Ejemplo n.º 56
0
 public bool CanDeleteClub()
 {
     return(Club.GetMemberInfoForSelf(this.ClubId).Value.role == 1 && this.m_memberList.Count < 2);
 }
Ejemplo n.º 57
0
        /// <summary>
        /// Creates a new club entity.
        /// </summary>
        /// <param name="club"></param>
        /// <returns></returns>
        public async Task <Club> CreateAsync(Club club)
        {
            await this.clubs.InsertOneAsync(club);

            return(club);
        }
 public void Refresh()
 {
     gvSchedSummary.DataSource = Club.ClubWithID(ClubID).GetUpcomingEvents(10, ResourceName, UserName);
     gvSchedSummary.DataBind();
 }
Ejemplo n.º 59
0
        public async Task <bool> Execute(GameServer server, Player plr, string[] args)
        {
            if (args.Length < 1)
            {
                if (plr.Account.SecurityLevel >= SecurityLevel.GameMaster)
                {
                    plr.SendConsoleMessage(S4Color.Red + "Wrong Usage, possible usages:");
                    plr.SendConsoleMessage(S4Color.Red + "> /clan forcejoin <username> <clan>");
                    plr.SendConsoleMessage(S4Color.Red + "> /clan forcekick <username> <clan>");
                    plr.SendConsoleMessage(S4Color.Red + "> /clan forcemaster <username> <clan>");
                    plr.SendConsoleMessage(S4Color.Red + "> /clan invite <username>");
                    plr.SendConsoleMessage(S4Color.Red + "> /clan kick <username>");
                }
                else
                {
                    plr?.SendAsync(new MessageChatAckMessage(
                                       ChatType.Channel,
                                       plr.Account.Id,
                                       "ClanMgr",
                                       "/clan invite <username>"));
                    plr?.SendAsync(new MessageChatAckMessage(
                                       ChatType.Channel,
                                       plr.Account.Id,
                                       "ClanMgr",
                                       "/clan kick <username>"));
                }
                return(true);
            }

            var isclanservice = args[0].ToLower() == "kick" && args[0].ToLower() == "invite";

            if (args.Length < 2)
            {
                Array.Resize(ref args, 3);
                args[1] = "none";
                args[2] = "none";
            }

            var nickname = args[1].ToLower();

            var tmp = new string[args.Length - 2];

            Array.Copy(args, 2, tmp, 0, tmp.Length);

            var clanb = new StringBuilder();

            foreach (var text in tmp)
            {
                clanb.Append(" " + text);
            }

            var clan = clanb.ToString().Trim().ToLower();

            Club club;

            if (plr?.Account.SecurityLevel >= SecurityLevel.GameMaster && !isclanservice)
            {
                club = GameServer.Instance.ClubManager.FirstOrDefault(x => x.ClanName.ToLower() == clan);
                if (club == null)
                {
                    plr.SendConsoleMessage(S4Color.Red + "Unknown clan " + clan);
                    return(true);
                }
            }
            else
            {
                club = plr?.Club;
                if (club == null)
                {
                    plr?.SendAsync(new MessageChatAckMessage(
                                       ChatType.Channel,
                                       plr.Account.Id,
                                       "ClanMgr",
                                       "You are not inside a clan"));
                    return(true);
                }
            }

            var player = GameServer.Instance.PlayerManager
                         .FirstOrDefault(x => x.Account?.Nickname?.ToLower() == nickname);
            AccountDto account;

            using (var db = AuthDatabase.Open())
            {
                account = (await DbUtil.FindAsync <AccountDto>(db, statement => statement
                                                               .Include <BanDto>(join => join.LeftOuterJoin())
                                                               .Where($"{nameof(AccountDto.Nickname):C} = @Nickname")
                                                               .WithParameters(new { Nickname = nickname }))).FirstOrDefault();

                if (account == null)
                {
                    if (player == null)
                    {
                        plr.SendConsoleMessage(S4Color.Red + "Unknown player");
                        return(true);
                    }

                    account = player.Account.AccountDto;
                }
            }

            switch (args[0].ToLower())
            {
            case "kick":
            {
                var message = "You cannot kick a player";
                var plrrank = plr.Club.GetPlayer(plr.Account.Id).Rank;
                if (plr.Account.Id == (ulong)account.Id)
                {
                    message = "You cannot kick yourself";
                }
                else if (plrrank <= ClubRank.Staff)
                {
                    if (club.GetPlayer((ulong)account.Id).Rank < plrrank)
                    {
                        message = "You cannot kick a player with a higher rank";
                    }
                    else
                    {
                        if (player != null)
                        {
                            Club.LogOff(player);
                        }
                        await club.RemovePlayer((ulong)account.Id);

                        message = "Kicked player from clan";
                    }
                }

                await plr.SendAsync(new MessageChatAckMessage(
                                        ChatType.Channel,
                                        plr.Account.Id,
                                        "ClanMgr",
                                        message));

                return(true);
            }

            case "invite":
            {
                var message = "You cannot invite a player";
                if (plr.Club.GetPlayer(plr.Account.Id).Rank <= ClubRank.Staff)
                {
                    if (player != null)
                    {
                        if (club.Players.ContainsKey(player.Account.Id))
                        {
                            message = "Player is already in your clan";
                        }
                        else
                        {
                            plr.Club.SendInvite(plr, player);
                            message = "Player has been invited";
                        }
                    }
                    else
                    {
                        message = "Player is not online";
                    }
                }

                await plr.SendAsync(new MessageChatAckMessage(
                                        ChatType.Channel,
                                        plr.Account.Id,
                                        "ClanMgr",
                                        message));

                return(true);
            }

            case "forcejoin":
            {
                if (plr.Account.SecurityLevel <= SecurityLevel.GameMaster)
                {
                    goto default;
                }

                if (GameServer.Instance.ClubManager.Any(x => x.Players.ContainsKey((ulong)account.Id)))
                {
                    plr.SendConsoleMessage(S4Color.Red + "Player is already in a clan");
                    return(true);
                }

                if (await club.AddPlayer((ulong)account.Id))
                {
                    plr?.SendConsoleMessage(S4Color.Green +
                                            $"Added player {account.Nickname} to clan {club.ClanName}");
                }

                return(true);
            }

            case "forcekick":
            {
                if (plr.Account.SecurityLevel <= SecurityLevel.GameMaster)
                {
                    goto default;
                }

                if (!GameServer.Instance.ClubManager.Any(x => x.Players.ContainsKey((ulong)account.Id)))
                {
                    plr.SendConsoleMessage(S4Color.Red + "Player is not in a clan");
                    return(true);
                }

                if (!club.Players.ContainsKey((ulong)account.Id))
                {
                    plr.SendConsoleMessage(S4Color.Red + "Player is in another clan");
                    return(true);
                }

                if (await club.RemovePlayer((ulong)account.Id))
                {
                    plr?.SendConsoleMessage(S4Color.Green +
                                            $"Removed player {account.Nickname} from clan {club.ClanName}");
                }

                return(true);
            }

            case "removestaff":
            {
                if (plr.Account.SecurityLevel <= SecurityLevel.GameMaster)
                {
                    goto default;
                }

                if (!GameServer.Instance.ClubManager.Any(x => x.Players.ContainsKey((ulong)account.Id)))
                {
                    plr.SendConsoleMessage(S4Color.Red + "Player is not in a clan");
                    return(true);
                }

                if (!club.Players.ContainsKey((ulong)account.Id))
                {
                    plr.SendConsoleMessage(S4Color.Red + "Player is in another clan");
                    return(true);
                }

                if (await club.ChangeStaffStatus((ulong)account.Id, false))
                {
                    plr?.SendConsoleMessage(S4Color.Green +
                                            $"Player {account.Nickname} is now Regular in {club.ClanName}");
                }

                return(true);
            }

            case "setstaff":
            {
                if (plr.Account.SecurityLevel <= SecurityLevel.GameMaster)
                {
                    goto default;
                }

                if (!GameServer.Instance.ClubManager.Any(x => x.Players.ContainsKey((ulong)account.Id)))
                {
                    plr.SendConsoleMessage(S4Color.Red + "Player is not in a clan");
                    return(true);
                }

                if (!club.Players.ContainsKey((ulong)account.Id))
                {
                    plr.SendConsoleMessage(S4Color.Red + "Player is in another clan");
                    return(true);
                }

                if (await club.ChangeStaffStatus((ulong)account.Id, true))
                {
                    plr?.SendConsoleMessage(S4Color.Green +
                                            $"Player {account.Nickname} is now staff in {club.ClanName}");
                }

                return(true);
            }

            case "forcemaster":
            {
                if (plr.Account.SecurityLevel <= SecurityLevel.GameMaster)
                {
                    goto default;
                }

                if (!GameServer.Instance.ClubManager.Any(x => x.Players.ContainsKey((ulong)account.Id)))
                {
                    plr.SendConsoleMessage(S4Color.Red + "Player is not in a clan");
                    return(true);
                }

                if (!club.Players.ContainsKey((ulong)account.Id))
                {
                    plr.SendConsoleMessage(S4Color.Red + "Player is in another clan");
                    return(true);
                }

                if (await club.ForceChangeMaster((ulong)account.Id))
                {
                    plr?.SendConsoleMessage(S4Color.Green +
                                            $"Changed Master from clan {club.ClanName} to player {account.Nickname}");
                }

                return(true);
            }

            default:
            {
                if (plr.Account.SecurityLevel >= SecurityLevel.GameMaster && !isclanservice)
                {
                    plr.SendConsoleMessage(S4Color.Red + "Wrong Usage, possible usages:");
                    plr.SendConsoleMessage(S4Color.Red + "> /clan forcejoin <username> <clan>");
                    plr.SendConsoleMessage(S4Color.Red + "> /clan forcekick <username> <clan>");
                    plr.SendConsoleMessage(S4Color.Red + "> /clan forcemaster <username> <clan>");
                    plr.SendConsoleMessage(S4Color.Red + "> /clan invite <username>");
                    plr.SendConsoleMessage(S4Color.Red + "> /clan kick <username>");
                }
                else
                {
                    plr?.SendAsync(new MessageChatAckMessage(
                                       ChatType.Channel,
                                       plr.Account.Id,
                                       "ClanMgr",
                                       "/clan invite <username>"));
                    plr?.SendAsync(new MessageChatAckMessage(
                                       ChatType.Channel,
                                       plr.Account.Id,
                                       "ClanMgr",
                                       "/clan kick <username>"));
                }

                return(true);
            }
            }
        }
Ejemplo n.º 60
0
 /// <summary>
 /// Updates a specific club entity
 /// </summary>
 /// <param name="id"></param>
 /// <param name="clubIn"></param>
 /// <returns></returns>
 public async Task UpdateAsync(string id, Club clubIn)
 {
     await this.clubs.ReplaceOneAsync(club => club.Id == id, clubIn);
 }