public void CanGetResult() { var mediator = new Mediator(); mediator.Subscribe<ChangeUserName, string>(message => new ReturnsName().Handle(message)); var command = new ChangeUserName { Name = "Foo Bar" }; var result = mediator.Send<ChangeUserName, string>(command); Assert.AreEqual("Foo Bar", result); }
public virtual async Task <ActionResult> Put(ChangeUserName command) { if (command == null) { return(View(MVC.Errors.Views.BadRequest)); } var view = await _queries.Execute(new UserViewBy(command.UserId)); if (view == null) { return(HttpNotFound()); } if (!ModelState.IsValid) { var model = new ChangeUserNameModel { UserView = view, Command = command, }; return(View(MVC.Security.Views.User.Settings, model)); } await _commands.Execute(command); Response.ClientCookie(command.SignedIn.Id, _queries); return(RedirectToAction(await MVC.UserName.Index())); }
public void CanSubscribeAIntResultWithoutAFunc() { var mediator = new Mediator(); mediator.Subscribe<ChangeUserName, int>(message => new Returns42().Handle(message)); var command = new ChangeUserName { Name = "Foo Bar" }; var result = mediator.Send<ChangeUserName, int>(command); Assert.AreEqual(42, result); }
public void CanSendWithoutResult() { var mediator = new Mediator(); var counter = new Counter(); mediator.Subscribe<ChangeUserName>(counter.Handle); var command = new ChangeUserName { Name = "Foo Bar" }; mediator.Send(command); Assert.AreEqual(1, counter.Count); }
public void CanGetResultWithASecondVoidHandler() { var mediator = new Mediator(); mediator.Subscribe<ChangeUserName, string>(message => { var r = new ReturnsName().Handle(message); new ConsoleLogger().Handle(message); return r; }); var command = new ChangeUserName { Name = "Foo Bar" }; var result = mediator.Send<ChangeUserName, string>(command); Assert.AreEqual("Foo Bar", result); }
public virtual ActionResult ValidatePut(ChangeUserName command) { //System.Threading.Thread.Sleep(new Random().Next(5000, 5001)); if (command == null) { Response.StatusCode = 400; return Json(null); } var result = new ValidatedFields(ModelState); //ModelState[command.PropertyName(x => x.UserName)].Errors.Clear(); //result = new ValidatedFields(ModelState, command.PropertyName(x => x.UserName)); return new CamelCaseJsonResult(result); }
public virtual ActionResult ValidatePut(ChangeUserName command) { //System.Threading.Thread.Sleep(new Random().Next(5000, 5001)); if (command == null) { Response.StatusCode = 400; return(Json(null)); } var result = new ValidatedFields(ModelState); //ModelState[command.PropertyName(x => x.UserName)].Errors.Clear(); //result = new ValidatedFields(ModelState, command.PropertyName(x => x.UserName)); return(new CamelCaseJsonResult(result)); }
//ユーザ名変更 public static void changeName(string newName) { NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("user"); query.WhereEqualTo("userName", getUserName()); query.FindAsync((List <NCMBObject> objList, NCMBException e) => { //検索成功したら if (e == null) { //HighScoreのほうの名前も変える NCMBQuery <NCMBObject> query2 = new NCMBQuery <NCMBObject>("HighScore"); query2.WhereEqualTo("userName", getUserName()); query2.FindAsync((List <NCMBObject> objList2, NCMBException e2) => { if (e2 == null) { objList2[0]["userName"] = newName; objList2[0].SaveAsync(); } }); objList[0]["userName"] = newName; objList[0].SaveAsync((NCMBException se) => { if (e == null) { NCMBUser.LogInAsync(newName, PlayerInformation.password); } }); userName = newName; PlayerInformation.setNamePass(newName, PlayerInformation.password); PhotonNetwork.playerName = newName; ChangeUserName.setMessage("変更しました"); } else { ChangeUserName.setMessage("エラー" + e.ErrorCode + ":" + e.Message); return; } }); }
public virtual async Task<ActionResult> Put(ChangeUserName command) { if (command == null) return View(MVC.Errors.Views.BadRequest); var view = await _queries.Execute(new UserViewBy(command.UserId)); if (view == null) return HttpNotFound(); if (!ModelState.IsValid) { var model = new ChangeUserNameModel { UserView = view, Command = command, }; return View(MVC.Security.Views.User.Settings, model); } await _commands.Execute(command); Response.ClientCookie(command.SignedIn.Id, _queries); return RedirectToAction(await MVC.UserName.Index()); }
public string Handle(ChangeUserName message) { return message.Name; }
public int Handle(ChangeUserName message) { return 42; }
public void Handle(ChangeUserName message) { //do persistence }
public void Handle(ChangeUserName message) { Count++; }
public void Handle(ChangeUserName message) { Console.WriteLine(message.Name); }