public ActionResult CreateUser(RegisterModel model) { User user = new User(); user.Id = model.Username; user.Password = model.Password; user.Email = model.Email; user.IsAdmin = model.IsAdmin; FoireMusesConnection connection = GetConnection(); user = connection.CreateUser(user, new Result<User>()).Wait(); return RedirectToAction("Index", "Home", null); }
public Result<User> CreateUser(User user, Result<User> aResult) { theServiceUri .At("users") .Post(DreamMessage.Ok(MimeType.JSON, user.ToString()), new Result<DreamMessage>()) .WhenDone(delegate(Result<DreamMessage> answer) { if (!answer.Value.IsSuccessful) { if (answer.Value.Status == DreamStatus.NotFound) aResult.Return((User)null); else aResult.Throw(answer.Exception); } else { aResult.Return(new User(JObject.Parse(answer.Value.ToText()))); } } ); return aResult; }