public ActionResult Edit(string sourceId)
		{
			FoireMusesConnection connection = GetConnection();
			Source source = null;
			try
			{
				if (sourceId != null)//get the score matching the id
				{
					source = connection.GetSource(sourceId, new Result<Source>()).Wait();
					if (source == null)
					{
						return RedirectToAction("Missing", "Error", null);
					}
					ViewBag.HeadTitle = "Edition";
				}
				else
				{
					source = new Source();
					ViewBag.HeadTitle = "Creation";
				}
			}
			catch (ArgumentException e)
			{
				ViewBag.Error = "Veuillez remplir les champs correctement";
				return View("Edit", source);
			}
			catch (Exception e)
			{
				return RedirectToAction("Problem", "Error", null);
			}
			return View("Edit", source);
		}
		public ActionResult Edit(Source model, FormCollection collection)
		{
			if (model == null)
			{
				return RedirectToAction("Problem", "Error", null);
			}
			if(!ValidateSource(model)){
				ViewBag.Error = "Certains champs sont mal rempli ou incomplet, veuillez les remplirs correctements.";
				if (model.Id != null)
					ViewBag.HeadTitle = "Edition";
				else
					ViewBag.HeadTitle = "Creation";
				return View("Edit", model);
			}
			FoireMusesConnection connection = GetConnection();
			try
			{
				//we use the same view to edit and create, so let's differentiate both
				if (model.Id == null)
				{
					model = connection.CreateSource(model, new Result<Source>()).Wait();
				}
				else
				{
					//when updating, first get the current score out of the db then update with values
					Source current = connection.GetSource(model.Id, new Result<Source>()).Wait();
					if (current == null)
						return RedirectToAction("Problem", "Error", null);
					TryUpdateModel(current);
					model = connection.EditSource(current, new Result<Source>()).Wait();
				}
			}
			catch (Exception e)
			{
				return RedirectToAction("Problem", "Error", null);
			}
			if (model == null)
				return RedirectToAction("Problem", "Error", null);
			//redirect to details
			return Redirect("Details?sourceId=" + model.Id);
		}
		private bool ValidateSource(Source source)
		{
			if (String.IsNullOrWhiteSpace(source.Name))
				return false;
			return true;
		}
		public Result<Source> EditSource(Source Source, Result<Source> aResult)
		{
			theServiceUri
				.At("sources")
				.With("id", Source.Id)
				.With("rev", Source.Rev)
				.Put(DreamMessage.Ok(MimeType.JSON, Source.ToString()), new Result<DreamMessage>())
				.WhenDone(delegate(Result<DreamMessage> answer)
				{
					if (!answer.Value.IsSuccessful)
					{
						if (answer.Value.Status == DreamStatus.NotFound)
							aResult.Return((Source)null);
						else
							aResult.Throw(answer.Exception);
					}
					else
					{
						aResult.Return(new Source(JObject.Parse(answer.Value.ToText())));
					}
				}
				);
			return aResult;
		}