public ActionResult SetConnection(ConnectionModel model) { var connections = new ConnectionService(); var response = connections.SetConnection(model); if (!response.Success) { model.Message = response.Message; return View("Index", model); } return RedirectToAction("Index", "Browse", null); }
public ApiResponse SetConnection(ConnectionModel model) { var builder = new MongoUrlBuilder(); var server = new MongoServerAddress(model.Server, model.Port ?? 27017); builder.Server = server; var url = builder.ToMongoUrl(); try { var conn = MongoServer.Create(url); conn.Connect(); conn.Disconnect(); } catch { return new ApiResponse(false, string.Format("Connection to {0} failed.", url)); } HttpContext.Current.Response.Cookies.Add(new HttpCookie("Mongo.Manager.Connection", url.ToString())); return new ApiResponse(); }
public ActionResult Index() { var model = new ConnectionModel(); return View(model); }