Exemple #1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            var phaseReportChars = db.PhaseReports.Where(x => x.MemberCharacter.Member_Id == id).ToList();

            db.BulkDelete(phaseReportChars);
            db = new SwgohDb();
            var phaseReportShips = db.PhaseReports.Where(x => x.MemberShip.Member_Id == id).ToList();

            db.BulkDelete(phaseReportShips);
            db = new SwgohDb();

            Member member = db.Members.Find(id);
            Guild  guild  = db.Guilds.Find(member.Guild_Id);

            guild.CharacterPower  = guild.CharacterPower - member.CharacterPower;
            guild.ShipPower       = guild.ShipPower - member.ShipPower;
            db.Entry(guild).State = EntityState.Modified;
            db.Members.Remove(member);
            db.Entry(guild).State = EntityState.Modified;
            db.SaveChanges();

            var tbps = db.TerritoryBattlePhases.Where(x => x.TerritoryBattle.Guild_Id == guild.Id);

            foreach (var tbp in tbps)
            {
                tbp.RefreshReport = true;
            }

            db.BulkUpdate(tbps);

            return(RedirectToAction("Details", "Guilds", new { id = member.Guild_Id }));
        }
 public ActionResult Edit(Guild guild)
 {
     if (ModelState.IsValid)
     {
         db.Entry(guild).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(guild));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,DisplayName,UrlExt,Alignment")] Ship ship)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ship).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ship));
 }
Exemple #4
0
 public ActionResult Edit(Character character)
 {
     if (ModelState.IsValid)
     {
         db.Entry(character).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(character));
 }
Exemple #5
0
 public ActionResult Edit(Member updateMember)
 {
     if (ModelState.IsValid)
     {
         db.Entry(updateMember).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "Guilds", new { id = updateMember.Guild_Id }));
     }
     ViewBag.Guild_Id = new SelectList(db.Guilds, "Id", "Name", updateMember.Guild_Id);
     return(RedirectToAction("Details", "Guilds", new { id = updateMember.Guild_Id }));
 }
        public ActionResult Edit(TerritoryBattlePhase territoryBattlePhase)
        {
            if (ModelState.IsValid)
            {
                db.Entry(territoryBattlePhase).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(territoryBattlePhase));
        }
Exemple #7
0
        public ActionResult Edit([Bind(Include = "Id,TotalPointsEarned,TerritoryPlatoon1_Id,TerritoryPlatoon2_Id,TerritoryPlatoon3_Id,TerritoryPlatoon4_Id,TerritoryPlatoon5_Id,TerritoryPlatoon6_Id")] PhaseTerritory phaseTerritory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(phaseTerritory).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(phaseTerritory));
        }
        public ActionResult Edit(TerritoryBattle territoryBattle)
        {
            if (ModelState.IsValid)
            {
                db.Entry(territoryBattle).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.Guild_Id = new SelectList(db.Guilds, "Id", "Name", territoryBattle.Guild_Id);

            return(View(territoryBattle));
        }
 public ActionResult Edit([Bind(Include = "Id,Level,Stars,Power,Ship_Id,Member_Id")] MemberShip memberShip)
 {
     if (ModelState.IsValid)
     {
         db.Entry(memberShip).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Member_Id = new SelectList(db.Members, "Id", "Name", memberShip.Member_Id);
     ViewBag.Ship_Id   = new SelectList(db.Ships, "Id", "Name", memberShip.Ship_Id);
     return(View(memberShip));
 }
        public ActionResult NewPlatoonAssignments(Guid id, Guid?memberId, Guid?guildId = null)
        {
            TerritoryBattlePhase tbp = db.TerritoryBattlePhases.Find(id);

            ViewBag.PhaseNumber = tbp.Phase;

            var members = db.Members.Where(x => x.Guild_Id == tbp.TerritoryBattle.Guild_Id).Select(s => new
            {
                Text  = s.DisplayName,
                Value = s.Id
            }).OrderBy(x => x.Text).AsEnumerable();

            SelectList selectList = new SelectList(members.ToList(), "Value", "Text");

            TerritoryPhaseReportModel model = new TerritoryPhaseReportModel()
            {
                Members  = selectList,
                MemberId = memberId,
                Id       = id,
            };

            ViewBag.GuildId = guildId;

            if (tbp.RefreshReport)
            {
                foreach (DictionaryEntry key in HttpContext.Cache)
                {
                    HttpContext.Cache.Remove(key.Key.ToString());
                }

                db.BulkDelete(db.PhaseReports.Where(x => x.TerritoryBattlePhase_Id == id).ToList());

                db = new SwgohDb();
                var tbpUpdate = db.TerritoryBattlePhases.Find(id);
                tbpUpdate.RefreshReport = false;

                db.Entry(tbpUpdate).State = EntityState.Modified;
                db.SaveChanges();
                db = new SwgohDb();
            }

            return(View(model));
        }
Exemple #11
0
        public ActionResult Edit(TerritoryPlatoonModel territoryPlatoonModel)
        {
            if (ModelState.IsValid)
            {
                TerritoryPlatoon territoryPlatoon = db.TerritoryPlatoons.Include(x => x.PlatoonCharacters).Include(x => x.PlatoonShips).SingleOrDefault(x => x.Id == territoryPlatoonModel.Id);

                if (territoryPlatoon.PlatoonCharacters.Count() != 0)
                {
                    var pcUpdate = new List <PlatoonCharacter>();

                    var character1  = territoryPlatoonModel.Character1;
                    var character2  = territoryPlatoonModel.Character2;
                    var character3  = territoryPlatoonModel.Character3;
                    var character4  = territoryPlatoonModel.Character4;
                    var character5  = territoryPlatoonModel.Character5;
                    var character6  = territoryPlatoonModel.Character6;
                    var character7  = territoryPlatoonModel.Character7;
                    var character8  = territoryPlatoonModel.Character8;
                    var character9  = territoryPlatoonModel.Character9;
                    var character10 = territoryPlatoonModel.Character10;
                    var character11 = territoryPlatoonModel.Character11;
                    var character12 = territoryPlatoonModel.Character12;
                    var character13 = territoryPlatoonModel.Character13;
                    var character14 = territoryPlatoonModel.Character14;
                    var character15 = territoryPlatoonModel.Character15;
                    pcUpdate.Add(character1);
                    pcUpdate.Add(character2);
                    pcUpdate.Add(character3);
                    pcUpdate.Add(character4);
                    pcUpdate.Add(character5);
                    pcUpdate.Add(character6);
                    pcUpdate.Add(character7);
                    pcUpdate.Add(character8);
                    pcUpdate.Add(character9);
                    pcUpdate.Add(character10);
                    pcUpdate.Add(character11);
                    pcUpdate.Add(character12);
                    pcUpdate.Add(character13);
                    pcUpdate.Add(character14);
                    pcUpdate.Add(character15);
                    db.BulkUpdate(pcUpdate);
                }
                else
                {
                    var psUpdate = new List <PlatoonShip>();

                    var ship1  = territoryPlatoonModel.Ship1;
                    var ship2  = territoryPlatoonModel.Ship2;
                    var ship3  = territoryPlatoonModel.Ship3;
                    var ship4  = territoryPlatoonModel.Ship4;
                    var ship5  = territoryPlatoonModel.Ship5;
                    var ship6  = territoryPlatoonModel.Ship6;
                    var ship7  = territoryPlatoonModel.Ship7;
                    var ship8  = territoryPlatoonModel.Ship8;
                    var ship9  = territoryPlatoonModel.Ship9;
                    var ship10 = territoryPlatoonModel.Ship10;
                    var ship11 = territoryPlatoonModel.Ship11;
                    var ship12 = territoryPlatoonModel.Ship12;
                    var ship13 = territoryPlatoonModel.Ship13;
                    var ship14 = territoryPlatoonModel.Ship14;
                    var ship15 = territoryPlatoonModel.Ship15;
                    psUpdate.Add(ship1);
                    psUpdate.Add(ship2);
                    psUpdate.Add(ship3);
                    psUpdate.Add(ship4);
                    psUpdate.Add(ship5);
                    psUpdate.Add(ship6);
                    psUpdate.Add(ship7);
                    psUpdate.Add(ship8);
                    psUpdate.Add(ship9);
                    psUpdate.Add(ship10);
                    psUpdate.Add(ship11);
                    psUpdate.Add(ship12);
                    psUpdate.Add(ship13);
                    psUpdate.Add(ship14);
                    psUpdate.Add(ship15);
                    db.BulkUpdate(psUpdate);
                }

                var tbp = db.TerritoryBattlePhases.Find(territoryPlatoon.PhaseTerritory.TerritoryBattlePhase_Id);

                tbp.RefreshReport = true;

                db.Entry(tbp).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Details", "TerritoryBattlePhases", new { id = territoryPlatoon.PhaseTerritory.TerritoryBattlePhase_Id }));
            }

            return(View(territoryPlatoonModel));
        }
        private void UpdateRoster(Guid id, Guild guild)
        {
            db = new SwgohDb();
            IEnumerable <Member>    members    = db.Members.Include(x => x.MemberCharacters).Include(x => x.MemberShips).Where(x => x.Guild_Id == id).ToList();
            IEnumerable <Character> characters = db.Characters.ToList();
            IEnumerable <Ship>      ships      = db.Ships.ToList();

            HtmlWeb      web = new HtmlWeb();
            HtmlDocument doc = web.Load(guild.UrlExt + "gp/");

            string guildMemberTable = doc.DocumentNode.SelectNodes("/html/body/div[3]/div[1]")[0].InnerHtml;

            guildMemberTable = guildMemberTable.Substring(guildMemberTable.IndexOf("<tbody>") + 7);
            Regex regexChar = new Regex(@"\n");
            Regex regex     = new Regex(@"<tr>");

            string[] substrings = regex.Split(guildMemberTable);
            //substrings = substrings.Skip(1).ToArray();
            List <string> listMembers = substrings.ToList();

            //listMembers.RemoveRange(0,2);

            listMembers.Remove("\n");

            List <Member>          newMembers          = new List <Member>();
            List <Member>          updateMembers       = new List <Member>();
            List <MemberCharacter> memberCharactersAdd = new List <MemberCharacter>();
            List <MemberShip>      memberShipsAdd      = new List <MemberShip>();

            List <Member> memberDelete = new List <Member>();

            List <string> memberExt = new List <string>();

            foreach (var member in listMembers)
            {
                string[] memberSplit = member.Split('"');
                memberExt.Add("https://swgoh.gg" + memberSplit[3] + "characters/");
            }

            foreach (var member in members)
            {
                if (!memberExt.Any(x => x.Contains(member.UrlExt)))
                {
                    memberDelete.Add(db.Members.FirstOrDefault(x => x.UrlExt == member.UrlExt));
                    db.SaveChanges();
                    db = new SwgohDb();
                }
            }
            foreach (var member in memberDelete)
            {
                var phaseReportChars = db.PhaseReports.Where(x => x.MemberCharacter.Member_Id == member.Id).ToList();
                db.BulkDelete(phaseReportChars);
                db = new SwgohDb();
                var phaseReportShips = db.PhaseReports.Where(x => x.MemberShip.Member_Id == member.Id).ToList();
                db.BulkDelete(phaseReportShips);
                db = new SwgohDb();
            }
            db.BulkDelete(memberDelete);
            db = new SwgohDb();

            foreach (var member in listMembers)
            {
                Member   guildMember = new Member();
                string[] memberSplit = member.Split('"');
                string   charHref    = "https://swgoh.gg" + memberSplit[3] + "characters/";
                string   shipHref    = "https://swgoh.gg" + memberSplit[3] + "ships/";
                string   name        = Regex.Replace(memberSplit[4], "(?s).*?(?<=<strong>)", String.Empty); // memberSplit[2].Substring(10).Replace("</strong>\n</a>\n</td>\n<td class=", "");
                name = name.Remove(name.IndexOf("</strong>", StringComparison.Ordinal));

                string toConvertChar = memberSplit[8].Replace(">", "").Replace(" ", "").Replace("</td\n<tdclass=", "");
                string toConvertShip = memberSplit[10].Replace(" ", "").Replace(">", "").Replace("</td\n</tr\n", "")
                                       .Replace("</tbody\n</table\n</div\n</li\n", "").Replace("</ul\n</div\n", "");

                if (members.Any(x => x.UrlExt.Equals(charHref)))
                {
                    guildMember                = members.FirstOrDefault(x => x.UrlExt.Equals(charHref));
                    guildMember.Name           = name;
                    guildMember.DisplayName    = HttpUtility.HtmlDecode(name);
                    guildMember.CharacterPower = Convert.ToInt32(toConvertChar);
                    guildMember.ShipPower      = Convert.ToInt32(toConvertShip);
                    updateMembers.Add(guildMember);
                }
                else
                {
                    guildMember.Id             = Guid.NewGuid();
                    guildMember.Name           = name;
                    guildMember.DisplayName    = HttpUtility.HtmlDecode(name);
                    guildMember.UrlExt         = charHref;
                    guildMember.Guild_Id       = guild.Id;
                    guildMember.CharacterPower = Convert.ToInt32(toConvertChar);
                    guildMember.ShipPower      = Convert.ToInt32(toConvertShip);
                    newMembers.Add(guildMember);
                }

                var memberCharacters = new List <MemberCharacter>();
                try
                {
                    memberCharacters = guildMember.MemberCharacters.ToList();// db.MemberCharacters.Where(x => x.Member_Id.Equals(guildMember.Id)).ToList();
                }
                catch
                {
                }
                string charHtml;

                HtmlDocument docMember = web.Load(charHref);
                try
                {
                    charHtml = docMember.DocumentNode.SelectNodes("//li[@class='media list-group-item p-a collection-char-list']")[0].InnerHtml;
                }
                catch (Exception ex)
                {
                    continue;
                }
                string[]      character      = regexChar.Split(charHtml);
                List <string> listCharacters = character.ToList();

                listCharacters.RemoveAll(x => x.Equals(""));
                listCharacters.RemoveAll(x => x.Equals("<div class=\"row\">"));
                listCharacters.RemoveAll(x => x.Equals("</a>"));
                listCharacters.RemoveAll(x => x.Equals("</div>"));
                listCharacters.RemoveAll(x => x.Equals("</span>"));
                listCharacters.RemoveAll(x => x.Equals("<span class=\"collection-char-gp-label-value\">"));
                listCharacters.RemoveAll(x => x.Equals("<div class=\"collection-char-gp-progress\">"));
                listCharacters.RemoveAll(x => x.Equals("<div class=\"char-portrait-full-gear\"></div>"));
                listCharacters.RemoveAll(x => x.Equals("<span class=\"collection-char-gp-label-percent\">%</span>"));
                listCharacters.RemoveAll(x => x.Equals("<div class=\"collection-char-gp-label\">"));
                listCharacters.RemoveAll(x => x.Equals("<div class=\"collection-char collection-char-light-side\">"));
                listCharacters.RemoveAll(x => x.Equals("<div class=\"collection-char collection-char-dark-side\">"));
                listCharacters.RemoveAll(x => x.Equals("<div class=\"col-xs-6 col-sm-3 col-md-3 col-lg-2\">"));

                var newMemberCharacter = new MemberCharacter
                {
                    Member_Id = guildMember.Id,
                    Id        = Guid.NewGuid()
                };

                foreach (var item in listCharacters)
                {
                    if (item.Contains("<div class=\"char-portrait-full-level"))
                    {
                        newMemberCharacter.Level = Convert.ToInt16(item.Trim().Substring(38, 2).Replace("<", ""));
                    }
                    else if (item.Contains("<div class=\"char-portrait-full-gear-level\">"))
                    {
                        var romanNum = Regex.Replace(item, "(?s).*?(?<=\">)", String.Empty);
                        romanNum = romanNum.Remove(romanNum.IndexOf("</", StringComparison.Ordinal));
                        switch (romanNum)
                        {
                        case "I":
                            newMemberCharacter.Gear = 1;
                            break;

                        case "II":
                            newMemberCharacter.Gear = 2;
                            break;

                        case "III":
                            newMemberCharacter.Gear = 3;
                            break;

                        case "IV":
                            newMemberCharacter.Gear = 4;
                            break;

                        case "V":
                            newMemberCharacter.Gear = 5;
                            break;

                        case "VI":
                            newMemberCharacter.Gear = 6;
                            break;

                        case "VII":
                            newMemberCharacter.Gear = 7;
                            break;

                        case "VIII":
                            newMemberCharacter.Gear = 8;
                            break;

                        case "IX":
                            newMemberCharacter.Gear = 9;
                            break;

                        case "X":
                            newMemberCharacter.Gear = 10;
                            break;

                        case "XI":
                            newMemberCharacter.Gear = 11;
                            break;

                        case "XII":
                            newMemberCharacter.Gear = 12;
                            break;
                        }
                    }
                    else if (item.Contains("<div class=\"collection-char-gp\""))
                    {
                        try
                        {
                            var toConvert = item.Substring(0, item.LastIndexOf('/'));
                            toConvert = toConvert.Substring(toConvert.LastIndexOf('r') + 2);
                            newMemberCharacter.Power = Convert.ToInt32(toConvert.Replace(",", ""));
                        }
                        catch
                        {
                            newMemberCharacter.Power = 0;
                        }
                    }
                    else if (item.Contains("<div class=\"star ") && !item.Contains("star-inactive"))
                    {
                        newMemberCharacter.Stars = Convert.ToInt16(item.Trim().Substring(21, 1));
                    }
                    else if (item.Contains("<img class=\"char-portrait-full-img\""))
                    {
                        var startIndex = item.IndexOf("alt=") + 5;
                        var endIndex   = item.IndexOf("height=") - 2 - startIndex;
                        //string charName = Regex.Replace(item, "<.*?>", String.Empty);
                        string charName = item.Substring(startIndex, endIndex);
                        IEnumerable <Character> charNames = characters.Where(x => x.Name.Equals(charName.Trim())).ToList();

                        if (charNames.Count() == 1)
                        {
                            newMemberCharacter.Character_Id = charNames.FirstOrDefault().Id;
                        }
                        else
                        {
                            if (charName.Contains("Fulcrum"))
                            {
                                newMemberCharacter.Character_Id = charNames.FirstOrDefault(x => x.Name.Equals("Ahsoka Tano (Fulcrum)")).Id;
                            }
                            else if (charName.Equals("Ahsoka Tano") || charName.Equals("hsoka Tano"))
                            {
                                newMemberCharacter.Character_Id = charNames.FirstOrDefault(x => x.Name.Equals("Ahsoka Tano")).Id;
                            }
                            else if (charName.Equals("Jawa"))
                            {
                                newMemberCharacter.Character_Id = charNames.FirstOrDefault(x => x.Name.Equals("Jawa")).Id;
                            }
                            else if (charName.Equals("Han Solo"))
                            {
                                newMemberCharacter.Character_Id = charNames.FirstOrDefault(x => x.Name.Equals("Han Solo")).Id;
                            }
                            else if (charName.Equals("Stormtrooper"))
                            {
                                newMemberCharacter.Character_Id = charNames.FirstOrDefault(x => x.Name.Equals("Stormtrooper")).Id;
                            }
                            else
                            {
                                newMemberCharacter.Character_Id = charNames.FirstOrDefault(x => x.Name.Substring(1).Contains(charName)).Id;
                            }
                        }
                    }
                    else if (item.Contains("<div class=\"collection-char-name\">"))
                    {
                        if (newMemberCharacter.Stars != null)
                        {
                            if (memberCharacters.Any(x => x.Character_Id.Equals(newMemberCharacter.Character_Id)))
                            {
                                MemberCharacter memberCharacterUpdate = memberCharacters.FirstOrDefault(x => x.Character_Id.Equals(newMemberCharacter.Character_Id));

                                memberCharacterUpdate.Level = newMemberCharacter.Level;
                                memberCharacterUpdate.Power = newMemberCharacter.Power;
                                memberCharacterUpdate.Stars = newMemberCharacter.Stars;
                                memberCharacterUpdate.Gear  = newMemberCharacter.Gear;

                                memberCharacters.Remove(memberCharacters.FirstOrDefault(x => x.Character_Id.Equals(newMemberCharacter.Character_Id)));
                                memberCharacters.Add(memberCharacterUpdate);
                            }
                            else
                            {
                                memberCharactersAdd.Add(newMemberCharacter);
                            }
                        }
                        newMemberCharacter = new MemberCharacter
                        {
                            Member_Id = guildMember.Id,
                            Id        = Guid.NewGuid()
                        };
                    }
                }
                if (memberCharacters.Count() != 0)
                {
                    db.BulkUpdate(memberCharacters);
                }
                db = new SwgohDb();
                List <MemberShip> memberShips = db.MemberShips.Where(x => x.Member_Id.Equals(guildMember.Id)).ToList();

                string shipHtml;

                HtmlDocument docShip = web.Load(shipHref);
                try
                {
                    shipHtml = docShip.DocumentNode.SelectNodes("//li[@class='media list-group-item p-a collection-char-list']")[0].InnerHtml;
                }
                catch
                {
                    continue;
                }
                string[]      ship      = regexChar.Split(shipHtml);
                List <string> listShips = ship.ToList();

                listShips.RemoveAll(x => x.Equals(""));
                listShips.RemoveAll(x => x.Equals("<div class=\"row\">"));
                listShips.RemoveAll(x => x.Equals("</a>"));
                listShips.RemoveAll(x => x.Equals("</div>"));
                listShips.RemoveAll(x => x.Equals("</span>"));
                listShips.RemoveAll(x => x.Equals("<span class=\"collection-char-gp-label-value\">"));
                listShips.RemoveAll(x => x.Equals("    \">"));
                listShips.RemoveAll(x => x.Equals("    "));
                listShips.RemoveAll(x => x.Equals("<div class=\"collection-ship-primary\">"));
                listShips.RemoveAll(x => x.Equals("<div class=\"collection-ship-main\">"));
                listShips.RemoveAll(x => x.Equals("<div class=\"collection-ship collection-ship-light-side\">"));
                listShips.RemoveAll(x => x.Equals("<div class=\"collection-ship collection-ship-dark-side\">"));
                listShips.RemoveAll(x => x.Equals("<div class=\"col-sm-6 col-md-6 col-lg-4\">"));
                listShips.RemoveAll(x => x.Equals("<div class=\"ship-portrait-full-frame\">"));
                listShips.RemoveAll(x => x.Equals("<div class=\"ship-portrait-full-frame-overlay\"></div>"));
                listShips.RemoveAll(x => x.Equals("<div class=\"ship-portrait-full-frame-image\">"));
                listShips.RemoveAll(x => x.Equals("<div class=\"collection-ship-secondary\">"));
                listShips.RemoveAll(x => x.Equals("<div class=\"collection-char-gp-progress\">"));
                listShips.RemoveAll(x => x.Equals("<div class=\"collection-char-gp-label\">"));
                listShips.RemoveAll(x => x.Equals("<span class=\"collection-char-gp-label-percent\">%</span>"));
                listShips.RemoveAll(x => x.StartsWith("<div class=\"collection-ship-crew"));
                listShips.RemoveAll(x => x.StartsWith("<div class=\"star star"));
                listShips.RemoveAll(x => x.StartsWith("<div class=\"char-portrait"));

                MemberShip newMemberShip = new MemberShip
                {
                    Member_Id = guildMember.Id,
                    Id        = Guid.NewGuid()
                };

                foreach (var item in listShips)
                {
                    if (item.Contains("<div class=\"ship-portrait-full-frame-level"))
                    {
                        newMemberShip.Level = Convert.ToInt16(item.Trim().Substring(44, 2).Replace("<", ""));
                    }
                    else if (item.Contains("\"Power "))
                    {
                        newMemberShip.Power = item.Trim().Substring(83).Replace("\">", "");
                        try
                        {
                            var toConvert = item.Substring(0, item.LastIndexOf('/'));
                            toConvert = toConvert.Substring(toConvert.LastIndexOf('r') + 2);
                            newMemberShip.ShipPower = Convert.ToInt32(toConvert.Replace(",", ""));
                        }
                        catch
                        {
                            newMemberShip.ShipPower = 0;
                        }
                    }
                    else if (item.Contains("ship-portrait-full-star") && !item.Contains("ship-portrait-full-star-inactive") && !item.Contains("stars"))
                    {
                        if (newMemberShip.Stars == null)
                        {
                            newMemberShip.Stars = 1;
                        }
                        else
                        {
                            newMemberShip.Stars = newMemberShip.Stars + 1;
                        }
                    }
                    else if (item.Contains("<a class=\"collection-ship-name-link\""))
                    {
                        var startIndex = item.IndexOf(">") + 1;
                        var endIndex   = item.IndexOf("</a") - startIndex;
                        //string charName = Regex.Replace(item, "<.*?>", String.Empty);
                        string shipName = item.Substring(startIndex, endIndex);
                        //var shipName = Regex.Replace(item, "<.*?>", string.Empty);
                        IEnumerable <Ship> shipNames = ships.Where(x => x.Name.Equals(shipName.Trim())).ToList();

                        if (shipNames.Count() == 1)
                        {
                            newMemberShip.Ship_Id = shipNames.FirstOrDefault().Id;
                        }
                        else
                        {
                            var blah = 1;
                        }

                        if (newMemberShip.Stars != null)
                        {
                            if (memberShips.Any(x => x.Ship_Id.Equals(newMemberShip.Ship_Id)))
                            {
                                MemberShip memberShipUpdate = memberShips.FirstOrDefault(x => x.Ship_Id.Equals(newMemberShip.Ship_Id));

                                memberShipUpdate.Level     = newMemberShip.Level;
                                memberShipUpdate.Power     = newMemberShip.Power;
                                memberShipUpdate.Stars     = newMemberShip.Stars;
                                memberShipUpdate.ShipPower = newMemberShip.ShipPower;

                                memberShips.Remove(memberShips.FirstOrDefault(x => x.Ship_Id.Equals(newMemberShip.Ship_Id)));
                                memberShips.Add(memberShipUpdate);
                            }
                            else
                            {
                                memberShipsAdd.Add(newMemberShip);
                            }
                        }
                        newMemberShip = new MemberShip
                        {
                            Member_Id = guildMember.Id,
                            Id        = Guid.NewGuid()
                        };
                    }
                }
                if (memberShips.Count != 0)
                {
                    db.BulkUpdate(memberShips);
                }
            }

            db.BulkUpdate(updateMembers);
            db = new SwgohDb();

            db.BulkInsert(newMembers);
            db = new SwgohDb();

            db.BulkInsert(memberCharactersAdd);
            db = new SwgohDb();

            db.BulkInsert(memberShipsAdd);
            db = new SwgohDb();

            var guildUpdate = db.Guilds.Find(id);
            var powers      = db.Members.Where(x => x.Guild_Id == id).ToList();

            guildUpdate.CharacterPower = powers.Sum(x => x.CharacterPower);
            guildUpdate.ShipPower      = powers.Sum(x => x.ShipPower);

            db.Entry(guildUpdate).State = EntityState.Modified;
            db.SaveChanges();
        }