Exemple #1
0
        public JsonResult doit2(Rq rq)
        {
            var rq_ =
                Some(rq)
                .Where(validator.IsValid)
                .ForEach(doit);

            return(Json(new { ok = false, rq = rq, rq_ = rq_, message = "IsValid rets option , so can be chained" }, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public JsonResult doit1(Rq rq)
        {
            var valid = validator.IsValid(rq);

            if (valid)
            {
                ///doit
            }
            return(Json(new { ok = valid, rq = rq, message = "IsValid rets bool, controller fun has an imperative if" }, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public JsonResult doit3(Rq rq)
        {
            var rq_ =
                Some(rq)                  // basketise in an Option
                .Map(Normalise)           // remove extra spaces, capitalise
                .Where(validator.IsValid) // is valid?
                .ForEach(doit);           // side effect

            return(Json(new { ok = false, rq = rq, rq_ = rq_, message = "IsValid rets option , controller fun ..." }, JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        public Rq Normalise(Rq rq)
        {
            if (rq != null)
            {
                rq.id = rq?.id?.Trim();
            }

            if (rq != null)
            {
                rq.name = rq?.name?.Trim().ToUpper();
            }

            return(rq);
        }
Exemple #5
0
 private void doit(Rq rq)
 {
     repo
     .Get(rq.id)
     .Bind(account => account.Debit(rq.transferAmount))
     .ForEach(account =>
     {
         // There are 2 statements here ...
         // They have side-effects and its both-together ...
         // create single Task representing both ops,
         // and have process that performs both
         // remove the task ONLY when both carried out
         // both ops may get performed more than once ...
         // => make provisions so  that both tasks are idempotent
         repo.Save(rq.id, account);
         swift.Wire(rq, account);
     });
 }