public ActionResult Add(PostNewTweetCommand command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();
            service.Execute(command);

            return RedirectToAction("Index");
        }
        bool DoRegister(RegisterModel model)
        {
            var service   = new Commanding.SimpleTwitterCommandServiceClient();
            var readModel = new ReadModelService.SimpleTwitterReadModelServiceClient();

            service.CreateUser(new CreateUserCommand()
            {
                Username = model.UserName
            });

            var user = readModel.GetUsers().Where(n => n.Username == model.UserName).SingleOrDefault();

            if (user == null)
            {
                ModelState.AddModelError("", "Command failed.");
                return(false);
            }

            service.SetUserPassword(new SetUserPasswordCommand()
            {
                UserID   = user.Id,
                Password = model.Password
            });

            service.SetUserProperty(new SetUserPropertyCommand()
            {
                UserID = user.Id,
                Name   = "Email",
                Value  = model.Email
            });

            FormsAuthentication.SetAuthCookie(model.UserName, createPersistentCookie: false);
            return(true);
        }
Beispiel #3
0
        static void SetProperty(Commands.SetUserPropertyCommand command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();

            if (command.Name == "IsAdmin")
            {
                if (command.Value == true.ToString())
                {
                    service.AddUserToRole(new Commands.AddUserToRoleCommand()
                    {
                        UserID = command.UserID,
                        Role   = "Admin"
                    });
                }
                else
                {
                    service.RemoveUserFromRole(new Commands.RemoveUserFromRoleCommand()
                    {
                        UserID = command.UserID,
                        Role   = "Admin"
                    });
                }
            }

            service.SetUserProperty(command);
        }
        public ActionResult Delete(Commands.DeleteUserCommand command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();
            service.DeleteUser(command);

            return RedirectToAction("Index");
        }
        public ActionResult Add(CreateNewChannelCommand command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();

            service.CreateNewChannel(command);

            return(RedirectToAction(""));
        }
Beispiel #6
0
        public ActionResult Delete(DeleteTweetCommand command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();

            service.Delete(command);

            return(RedirectToAction("Index"));
        }
        public ActionResult Add(Commanding.CreateNewChannelCommand command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();

            service.CreateNewChannel(command);

            return RedirectToAction("");
        }
Beispiel #8
0
        public ActionResult Add(PostNewTweetCommand command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();

            service.Execute(command);

            return(RedirectToAction("Index"));
        }
        public ActionResult Add(Models.UserModel item)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();
            service.CreateUser(new Commands.CreateUserCommand()
                {
                    Username = item.Username
                });

            return RedirectToAction("Index");
        }
        public static void SignOff()
        {
            FormsAuthentication.SignOut();

            var service = new Commanding.SimpleTwitterCommandServiceClient();
            service.InvalidateUser(new InvalidateUserCommand()
            {
                UserID = (Guid)HttpContext.Current.Session["UserID"]
            });
        }
Beispiel #11
0
        public static void SignOff()
        {
            FormsAuthentication.SignOut();

            var service = new Commanding.SimpleTwitterCommandServiceClient();

            service.InvalidateUser(new InvalidateUserCommand()
            {
                UserID = (Guid)HttpContext.Current.Session["UserID"]
            });
        }
Beispiel #12
0
        public ActionResult Add(Models.UserModel item)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();

            service.CreateUser(new Commands.CreateUserCommand()
            {
                Username = item.Username
            });

            return(RedirectToAction("Index"));
        }
Beispiel #13
0
        public ActionResult SetPassword(Models.ChangePasswordModel command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();

            service.SetUserPassword(new Commands.SetUserPasswordCommand()
            {
                UserID   = command.UserID,
                Password = command.NewPassword
            });

            return(RedirectToAction("Details", new { id = command.UserID }));
        }
        public static bool UserValidated(LogOnModel model)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();
            var readModel = new ReadModelService.SimpleTwitterReadModelServiceClient();
            var user = readModel.GetUsers().Where(n => n.Username == model.UserName).SingleOrDefault();
            if (user == null)
            {
                return false;
            }

            service.ValidateUser(new ValidateUserCommand()
            {
                UserID = user.Id,
                Username = model.UserName,
                Password = model.Password
            });

            bool validated = readModel.UserValidated(user.Id);

            return validated;
        }
Beispiel #15
0
        public static bool UserValidated(LogOnModel model)
        {
            var service   = new Commanding.SimpleTwitterCommandServiceClient();
            var readModel = new ReadModelService.SimpleTwitterReadModelServiceClient();
            var user      = readModel.GetUsers().Where(n => n.Username == model.UserName).SingleOrDefault();

            if (user == null)
            {
                return(false);
            }

            service.ValidateUser(new ValidateUserCommand()
            {
                UserID   = user.Id,
                Username = model.UserName,
                Password = model.Password
            });

            bool validated = readModel.UserValidated(user.Id);

            return(validated);
        }
Beispiel #16
0
        public ActionResult Validate(string username, string submittedPassword)
        {
            var service   = new Commanding.SimpleTwitterCommandServiceClient();
            var readModel = new ReadModelService.SimpleTwitterReadModelServiceClient();

            var user = readModel.GetUsers().Where(n => n.Username == username).SingleOrDefault();

            if (user == null)
            {
                return(View(false));
            }

            service.ValidateUser(new Commands.ValidateUserCommand()
            {
                UserID   = user.Id,
                Username = username,
                Password = submittedPassword
            });

            bool result = readModel.UserValidated(user.Id);

            return(View(result));
        }
        public ActionResult SetPassword(Commanding.SetUserPasswordCommand command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();
            service.SetUserPassword(command);

            return RedirectToAction("Details", new { id = command.UserID });
        }
        static void SetProperty(Commands.SetUserPropertyCommand command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();
            if (command.Name == "IsAdmin")
            {
                if (command.Value == true.ToString())
                {
                    service.AddUserToRole(new Commands.AddUserToRoleCommand()
                        {
                            UserID = command.UserID,
                            Role = "Admin"
                        });
                }
                else
                {
                    service.RemoveUserFromRole(new Commands.RemoveUserFromRoleCommand()
                        {
                            UserID = command.UserID,
                            Role = "Admin"
                        });
                }
            }

            service.SetUserProperty(command);
        }
        public ActionResult Validate(string username, string submittedPassword)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();
            var readModel = new ReadModelService.SimpleTwitterReadModelServiceClient();

            var user = readModel.GetUsers().Where(n => n.Username == username).SingleOrDefault();

            if (user == null)
            {
                return View(false);
            }

            service.ValidateUser(new Commands.ValidateUserCommand()
            {
                UserID = user.Id,
                Username = username,
                Password = submittedPassword
            });

            bool result = readModel.UserValidated(user.Id);

            return View(result);
        }
        public ActionResult SetPassword(Models.ChangePasswordModel command)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();
            service.SetUserPassword(new Commands.SetUserPasswordCommand()
                {
                    UserID = command.UserID,
                    Password = command.NewPassword
                });

            return RedirectToAction("Details", new { id = command.UserID });
        }
 static void SetProperty(Commanding.SetUserPropertyCommand command)
 {
     var service = new Commanding.SimpleTwitterCommandServiceClient();
     service.SetUserProperty(command);
 }
        bool DoRegister(RegisterModel model)
        {
            var service = new Commanding.SimpleTwitterCommandServiceClient();
            var readModel = new ReadModelService.SimpleTwitterReadModelServiceClient();
            service.CreateUser(new CreateUserCommand()
            {
                Username = model.UserName
            });

            var user = readModel.GetUsers().Where(n => n.Username == model.UserName).SingleOrDefault();

            if (user == null)
            {
                ModelState.AddModelError("", "Command failed.");
                return false;
            }

            service.SetUserPassword(new SetUserPasswordCommand()
            {
                UserID = user.Id,
                Password = model.Password
            });

            service.SetUserProperty(new SetUserPropertyCommand()
            {
                UserID = user.Id,
                Name = "Email",
                Value = model.Email
            });

            FormsAuthentication.SetAuthCookie(model.UserName, createPersistentCookie: false);
            return true;
        }