public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Active")] Hiring hiring)
        {
            if (id != hiring.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hiring);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HiringExists(hiring.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hiring));
        }
 /// <summary>
 /// Decodes the <see cref="Message" />, using the <see cref="Reader" /> instance.
 /// </summary>
 internal override void Decode()
 {
     this.Description   = this.Reader.ReadString();
     this.BadgeType     = this.Reader.ReadVInt();
     this.BadgeID       = this.Reader.ReadVInt();
     this.Type          = (Hiring)this.Reader.ReadVInt();
     this.RequiredScore = this.Reader.ReadVInt();
 }
        /// <summary>
        /// Decodes the <see cref="Message" />, using the <see cref="Reader" /> instance.
        /// </summary>
        internal override void Decode()
        {
            this.Name        = this.Reader.ReadString();
            this.Description = this.Reader.ReadString();

            this.BadgeType = this.Reader.ReadVInt();          // Badge Type
            this.BadgeID   = this.Reader.ReadVInt();          // Badge ID

            this.Hiring           = (Hiring)this.Reader.ReadVInt();
            this.RequiredTrophies = this.Reader.ReadVInt();
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Active")] Hiring hiring)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hiring);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hiring));
        }
Exemple #5
0
 public Alliance()
 {
     //m_vChatMessages = new List<StreamEntry>();
     m_vAllianceMembers     = new Dictionary <long, Members>(m_vMaxAllianceMembers);
     m_vAllianceType        = Hiring.OPEN;
     m_vAllianceName        = "Default";
     m_vAllianceDescription = "Default";
     m_vAllianceBadgeData   = 0;
     m_vRequired_Trophies   = 0;
     m_vAllianceOrigin      = 0x01E84857; // 32000087
 }
 public override void Decode()
 {
     Name              = Reader.ReadString();
     Description       = Reader.ReadString();
     Badge             = Reader.ReadInt32();
     Type              = (Hiring)Reader.ReadInt32();
     Required_Trophies = Reader.ReadInt32();
     War_Frequency     = Reader.ReadInt32();
     Origin            = Reader.ReadInt32();
     War_History       = Reader.ReadByte() > 0;
     War_Amical        = Reader.ReadByte() > 0;
 }
        /// <summary>
        /// Processes this instance.
        /// </summary>
        internal override void Process()
        {
            if (this.ValuesAreValid)
            {
                if (this.Device.Player.ClanLowID > 0)
                {
                    this.Clan = Resources.Clans.Get(this.Device.Player.ClanHighID, this.Device.Player.ClanLowID, Constants.Database, false);

                    if (this.Clan != null)
                    {
                        Member Member;

                        if (this.Clan.Members.Entries.TryGetValue(this.Device.Player.PlayerID, out Member))
                        {
                            if (Member.Role == Role.Co_Leader || Member.Role == Role.Leader)
                            {
                                this.Clan.Description       = this.Description;
                                this.Clan.Badge             = this.Badge;
                                this.Clan.Type              = this.Type;
                                this.Clan.Required_Trophies = this.RequiredScore;

                                new Clan_Edit_OK(this.Device).Send();
                                new Clan_Info(this.Device, this.Clan).Send();
                            }
                            else
                            {
                                Logging.Error(this.GetType(), "Failed to edit the clan, player has not rights.");
                            }
                        }
                        else
                        {
                            Logging.Error(this.GetType(), "Failed to edit the clan, TryGetValue(PlayerID, out Member) returned false.");
                        }
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Clan was null when Process() has been called.");
                    }
                }
                else
                {
                    Logging.Error(this.GetType(), "Failed to edit the clan, player is not in a clan.");
                }
            }
            else
            {
                Logging.Error(this.GetType(), "Failed to edit the clan, values were not valid.");
            }
        }
Exemple #8
0
        /// <summary>
        /// Decodes this instance.
        /// </summary>
        internal override void Decode()
        {
            this.Name        = this.Reader.ReadString();
            this.Description = this.Reader.ReadString();

            this.AllianceBadge = this.Reader.ReadInt32();
            this.AllianceType  = (Hiring)this.Reader.ReadInt32();
            this.RequiredScore = this.Reader.ReadInt32();
            this.WarFrequency  = this.Reader.ReadInt32();

            this.Origin = this.Reader.ReadData <RegionData>();

            this.PublicWarLog = this.Reader.ReadBoolean();
            this.AmicalWar    = this.Reader.ReadBoolean();
        }
Exemple #9
0
        /// <summary>
        /// Deserialize the specified JSON.
        /// </summary>
        /// <param name="_Data">The JSON.</param>
        public void LoadFromJSON(string _Data)
        {
            JObject _Json = JObject.Parse(_Data);

            this.ClanID   = _Json["clan_id"].ToObject <long>();
            this.BackupID = _Json["backup_id"].ToObject <long>();

            this.Trophies          = _Json["trophies"].ToObject <int>();
            this.Required_Trophies = _Json["required_trophies"].ToObject <int>();
            this.Origin            = _Json["origin"].ToObject <int>();
            this.Badge             = _Json["badge"].ToObject <int>();

            this.Name        = _Json["name"].ToObject <string>();
            this.Description = _Json["description"].ToObject <string>();

            this.Type = (Hiring)_Json["type"].ToObject <int>();
        }
Exemple #10
0
 public Alliance(long id)
 {
     m_vAllianceId          = id;
     m_vAllianceBackupId    = id;
     m_vAllianceName        = "Default";
     m_vAllianceDescription = "Default";
     m_vAllianceBadgeData   = 0;
     m_vAllianceType        = Hiring.OPEN;
     m_vRequired_Trophies   = 0;
     //m_vWarFrequency = 0;
     m_vAllianceOrigin = 0x01E84857; // 32000087
     //m_vScore = 10000;
     //m_vAllianceExperience = 8599;
     //m_vAllianceLevel = 10;
     //m_vWonWars = 0;
     //m_vLostWars = 0;
     //m_vDrawWars = 0;
     //m_vChatMessages = new List<StreamEntry>();
     m_vAllianceMembers = new Dictionary <long, Members>(m_vMaxAllianceMembers);
 }
Exemple #11
0
        public void LoadFromJSON(string jsonString)
        {
            JObject jsonObject = JObject.Parse(jsonString);

            m_vAllianceId        = jsonObject["alliance_id"].ToObject <long>();
            m_vAllianceBackupId  = jsonObject["alliance_backup_id"].ToObject <long>();
            m_vAllianceName      = jsonObject["alliance_name"].ToObject <string>();
            m_vAllianceBadgeData = jsonObject["alliance_badge"].ToObject <int>();
            m_vAllianceType      = (Hiring)jsonObject["alliance_type"].ToObject <int>();
            m_vTrophies          = jsonObject["trophies"].ToObject <int>();
            m_vRequired_Trophies = jsonObject["required_trophies"].ToObject <int>();
            m_vAllianceOrigin    = jsonObject["origin"].ToObject <int>();
            //if (jsonObject["required_score"] != null)
            //m_vRequiredScore = jsonObject["required_score"].ToObject<int>();
            //m_vScore = jsonObject["score"].ToObject<int>();
            m_vAllianceDescription = jsonObject["description"].ToObject <string>();
            //m_vAllianceExperience = jsonObject["alliance_experience"].ToObject<int>();
            //m_vAllianceLevel = jsonObject["alliance_level"].ToObject<int>();
            //if (jsonObject["won_wars"] != null)
            //    m_vWonWars = jsonObject["won_wars"].ToObject<int>();
            //if (jsonObject["lost_wars"] != null)
            //    m_vLostWars = jsonObject["lost_wars"].ToObject<int>();
            //if (jsonObject["draw_wars"] != null)
            //    m_vDrawWars = jsonObject["draw_wars"].ToObject<int>();
            //if (jsonObject["war_frequency"] != null)
            //    m_vWarFrequency = jsonObject["war_frequency"].ToObject<int>();
            //if (jsonObject["alliance_origin"] != null)
            //    m_vAllianceOrigin = jsonObject["alliance_origin"].ToObject<int>();

            //JArray jsonMembers = (JArray)jsonObject["members"];
            //foreach (JObject jsonMember in jsonMembers)
            //{
            //    long id = jsonMember["avatar_id"].ToObject<long>();
            //    AllianceMemberEntry member = new AllianceMemberEntry(id);
            //    member.Load(jsonMember);
            //    m_vAllianceMembers.Add(id, member);
            //}
        }
Exemple #12
0
 public void SetAllianceType(Hiring status)
 {
     m_vAllianceType = status;
 }