示例#1
0
        public void FlashDiscard()
        {
            Flash flash = new Flash();

            flash.Add("test1", "hello");
            flash.Add("test2", "hello");

            flash.Discard("test2");

            flash.Sweep();

            Assert.IsTrue(flash.ContainsKey("test1"));
            Assert.IsFalse(flash.ContainsKey("test2"));

            flash = new Flash(flash);
            flash.Sweep();

            Assert.IsTrue(flash.Count == 0);

            flash.Add("test1", "hello");
            flash.Add("test2", "hello");

            flash.Discard();

            flash = new Flash(flash);
            flash.Sweep();

            Assert.IsFalse(flash.ContainsKey("test1"));
            Assert.IsFalse(flash.ContainsKey("test2"));
        }
示例#2
0
        public void SavePassword(string hash, string password, string passwordCheck)
        {
            // password1 omdat 'password' ervoor zorgt dat bij redirect naar inlogpagina, het wachtwoordveld al wordt ingevuld
            if (password != passwordCheck)
            {
                PropertyBag.Add("error", "De wachtwoorden komen niet overeen. Probeer opnieuw.");
                PropertyBag.Add("hash", hash);
                RenderView("changepassword");
            }

            // check if hash (customer) exists
            var users = session.QueryOver <User>().Where(x => x.IsActive).And(x => x.Password.Hash == hash).List();

            // if hash (customer) exists
            if (users.Count > 0)
            {
                users[0].Password = new Password(password);
                using (var tx = session.BeginTransaction())
                {
                    session.SaveOrUpdate(users[0]);
                    tx.Commit();
                }

                Flash.Add("message", "Uw wachtwoord is met succes gewijzigd. U kunt hieronder inloggen met uw nieuwe wachtwoord.");
                RenderView("index");
                Index("", "", false, "");
            }
            else
            {
                RedirectToAction("ChangePassword", new Hashtable {
                    { "hash", hash }
                });
            }
        }
        public void InnerAction()
        {
            CancelView();

            Flash.Add("errormessage", "Some error");

            RenderText("<h2>Executed InnerAction</h2>");
        }
        public void FlashDiscard()
        {
            var flash = new Flash
            {
                { "test1", "hello" },
                { "test2", "hello" }
            };

            flash.Discard("test2");

            flash.Sweep();

            Assert.IsTrue(flash.ContainsKey("test1"));
            Assert.IsFalse(flash.ContainsKey("test2"));

            flash = new Flash(flash);
            flash.Sweep();

            Assert.IsTrue(flash.Count == 0);

            flash.Add("test1", "hello");
            flash.Add("test2", "hello");

            flash.Discard();

            flash = new Flash(flash);
            flash.Sweep();

            Assert.IsFalse(flash.ContainsKey("test1"));
            Assert.IsFalse(flash.ContainsKey("test2"));

            flash = new Flash
            {
                { "test1", "hello" },
                { "test1", "hello update" }
            };

            Assert.AreEqual("hello update", flash["test1"]);

            flash.Discard("test1");

            flash.Sweep();

            Assert.IsFalse(flash.ContainsKey("test1"));
        }
示例#5
0
        public void WhenUsingDiscard_ItemsIsNotKept()
        {
            var flash = new Flash
            {
                { "test1", "hello" },
                { "test2", "hello" }
            };

            flash.Discard("test2");

            flash.Sweep();

            Assert.IsTrue(flash.ContainsKey("test1"));
            Assert.IsFalse(flash.ContainsKey("test2"));

            flash = new Flash(flash);
            flash.Sweep();

            Assert.IsTrue(flash.Count == 0);

            flash.Add("test1", "hello");
            flash.Add("test2", "hello");

            flash.Discard();

            flash = new Flash(flash);
            flash.Sweep();

            Assert.IsFalse(flash.ContainsKey("test1"));
            Assert.IsFalse(flash.ContainsKey("test2"));

            flash = new Flash
            {
                { "test1", "hello" },
                { "test1", "hello update" }
            };

            Assert.AreEqual("hello update", flash["test1"]);

            flash.Discard("test1");

            flash.Sweep();

            Assert.IsFalse(flash.ContainsKey("test1"));
        }
示例#6
0
        public void BookTime(string projectSlug, int issueId, string date, double hours, bool close)
        {
            RedirectToReferrer();
            if (hours <= 0.0)
            {
                Flash.Add("error", "Geen uren ingevuld, niets geboekt naar Freckle");
                RedirectToReferrer();
                return;
            }
            var project = session.Query <Project>().FirstOrDefault(p => p.Slug == projectSlug);
            var issue   = session.Query <Issue>().FirstOrDefault(i => i.Number == issueId && i.Project == project);

            if (issue.IsArchived)
            {
                return;
            }
            var labels      = project.Labels.Where(l => l.ToFreckle && issue.Labels.Select(label => label.Name).Contains(l.Name)).Select(l => l.Name).ToList();
            var description = string.Format("{0}, !!#{1} - {2}", string.Join(",", labels), issue.Number, issue.Name);
            var entry       = new Entry()
            {
                Date        = date,
                Description = description,
                Minutes     = string.Format("{0}h", hours),
                ProjectId   = project.FreckleId,
                User        = CurrentUser.FreckleEmail
            };

            if (entryClient.Post(entry))
            {
                Flash.Add("info", "Uren geboekt in Freckle");
                if (close)
                {
                    issue.Close(CurrentUser);
                    using (var tx = session.BeginTransaction())
                    {
                        session.SaveOrUpdate(issue);
                        tx.Commit();
                    }
                }
            }
            else
            {
                Flash.Add("error", "Er is iets mis gegaan met boeken in Freckle");
            }
        }
示例#7
0
        public void Flash1()
        {
            Flash.Add("errormessage", "Some error");

            RenderText("RenderText output");
        }
 public void Index()
 {
     Flash.Add("errorfgfgmessage", "Some error");
 }