コード例 #1
0
        public ActionResult Save(string message)
        {
            if (!string.IsNullOrEmpty(message))
            {
                using (var entities = new ClanManagerEntities())
                {
                    entities.Suggestion.Add(new Suggestion
                    {
                        Message  = message,
                        DateTime = DateTime.Now
                    });

                    entities.SaveChanges();
                }
            }
            return(Json("Success"));
        }
コード例 #2
0
        private void ATimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            var clashRoyaleApi   = new ClashRoyaleApi();
            var clashRoyaleApiUk = new ClashRoyaleApi("PL8YLLUC");


            var clanInfo = clashRoyaleApi.GetClanInfo();

            var ukClanInfo = clashRoyaleApiUk.GetClanInfo();

            var allMambers = clanInfo.members.ToList();

            allMambers.AddRange(ukClanInfo.members);

            using (var entities = new ClanManagerEntities())
            {
                var existingMembers = entities.Member;

                if (existingMembers.Any())
                {
                    foreach (var member in existingMembers)
                    {
                        if (!allMambers.Any(s => s.tag != member.Tag))
                        {
                            entities.Member.Remove(member);
                        }
                    }
                }

                foreach (var member in allMambers)
                {
                    if (!existingMembers.Any(s => s.Tag == member.tag))
                    {
                        entities.Member.Add(new Member
                        {
                            JoinDate = DateTime.Now,
                            Name     = member.name,
                            Tag      = member.tag
                        });
                    }
                }

                entities.SaveChanges();
            }
        }