Exemplo n.º 1
0
        public override void Execute(IDataContext context)
        {
            ContextQuery = ctx =>
            {
                var user = ctx.AsQueryable <User>().SingleOrDefault(t => t.Id == UserId);
                if (user == null)
                {
                    throw new DomainException($"User with Id '{UserId}' could not be found");
                }

                var moderator = ctx.AsQueryable <User>().SingleOrDefault(t => t.Id == ModeratorId);
                if (moderator == null)
                {
                    throw new DomainException($"Moderator with Id '{ModeratorId}' could not be found");
                }

                var player = ctx.AsQueryable <Player>()
                             .Include(p => p.PlayerLogs)
                             .SingleOrDefault(p => p.User.Id == UserId);

                if (player != null)
                {
                    player.AddLog($"<b class='bad'>You have received a strike against your account from a moderator.  Reason cited: {Reason}.</b>", true);
                }

                var entry = Strike.Create(user, moderator, Reason, Round);

                ctx.Add(entry);
                ctx.Commit();
            };

            ExecuteInternal(context);
        }
Exemplo n.º 2
0
        public void CheckReportCreation(string text, string expected)
        {
            Strike testObject = new Strike(text);
            string actual     = testObject.Create();

            Assert.Equal(expected, actual);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string text = string.Empty;

            DA.GetData(0, ref text);

            string reportPart;
            Strike reportObject = new Strike(text);

            reportPart = reportObject.Create();

            DA.SetData(0, reportPart);
        }