public ActionResult Publish(string scoreId, bool overwrite, HttpPostedFileBase file) { theLogger.Info("POST Publish"); if (file == null || file.ContentType != "text/xml" || file.ContentLength == 0) { ViewBag.Error = "Error during the upload, please be sure to choose a valid xml file from your computer"; return(View("Publish")); } FoireMusesConnection connection = GetConnection(); Score score = null; try { if (scoreId == null) { XDoc theDoc = XDocFactory.From(file.InputStream, MimeType.XML); score = connection.CreateScoreWithXml(theDoc, new Result <Score>()).Wait(); } else { Score current = connection.GetScore(scoreId, new Result <Score>()).Wait(); if (current == null) { return(RedirectToAction("Missing", "Error", null)); } score = connection.UpdateScoreWithXml(current.Id, current.Rev, XDocFactory.From(file.InputStream, MimeType.XML), overwrite, new Result <Score>()).Wait(); if (score == null) { return(RedirectToAction("Problem", "Error", null)); } return(RedirectToAction("Details", new { scoreId = score.Id })); } } catch (Exception e) { theLogger.Error("Stacktrace:\n" + e.StackTrace); return(RedirectToAction("Problem", "Error", null)); } return(RedirectToAction("Edit", new { scoreId = score.Id })); }