Example #1
0
        public JsonResult PayBill(BillingInformation billInfo)
        {
            var context = invoker.Invoke(new InvokerContext(
                                             new PayCurrentBill(),
                                             new { CompanyName = Session["CompanyName"], billInfo.UserAccountData }));

            if (!context.Results.PaymentSucceeded)
            {
                return(ControllerExtensions.CreateModelErrors(this, context.Messages.ToArray()));
            }

            return(Json(new { Success = true, context.Messages }));
        }
Example #2
0
        public JsonResult Unregister()
        {
            var context = invoker.Invoke(new InvokerContext(
                                             new UserUnregistration(),
                                             new { CompanyName = Session["CompanyName"] }
                                             ));

            if (!context.Results.UserUnregistered)
            {
                return(ControllerExtensions.CreateModelErrors(this, context.Messages.ToArray()));
            }

            TempData["Messages"] = context.Messages;
            FormsAuthentication.SignOut();
            return(Json(new { Success = true, RedirectURL = Url.Action("Index", "Account") }));
        }
Example #3
0
        public JsonResult Register(Credentials credentials)
        {
            if (!ModelState.IsValid)
            {
                return(ControllerExtensions.CreateModelValidationResult(this));
            }

            var context = invoker.Invoke(new InvokerContext(new UserRegistration(), credentials));

            if (!context.Results.UserRegistered)
            {
                return(ControllerExtensions.CreateModelErrors(this, context.Messages.ToArray()));
            }

            TempData["Messages"] = context.Messages;

            return(Json(new { Success = true, RedirectURL = Url.Action("Index") }));
        }
Example #4
0
        public JsonResult Login(Credentials credentials)
        {
            if (!ModelState.IsValid)
            {
                return(ControllerExtensions.CreateModelValidationResult(this));
            }

            var context = invoker.Invoke(new InvokerContext(new UserLogin(), credentials));

            if (!context.Results.LoggedIn)
            {
                return(ControllerExtensions.CreateModelErrors(this, context.Messages.ToArray()));
            }

            TempData["Messages"] = context.Messages;

            FormsAuthentication.SetAuthCookie(credentials.CompanyName, false);
            Session["CompanyName"] = credentials.CompanyName;
            return(Json(new { Success = true, RedirectURL = Url.Action("Index", "Home") }));
        }