public ActionResult Create(RepositoryModel model) { if (ModelState.IsValid) { bool badName; var repo = RepositoryService.Create(model, Token.UserID, out badName); if (repo != null) { var success = GitService.CreateRepository(model.Name); if (!success) { RepositoryService.Delete(model.Name); repo = null; } } if (repo != null) { return(RedirectToAction("Detail", "Repository", new { name = repo.Name })); } if (badName) { ModelState.AddModelError("Name", SR.Repository_AlreadyExists); } } return(View(model)); }
public ActionResult Create(RepositoryModel model) { if (ModelState.IsValid) { try { var repo = RepositoryService.Create(model); if (repo != null) { var success = GitService.CreateRepository(model.Owner, model.Name); if (!success) { RepositoryService.Delete(Token.Username, model.Name); repo = null; } } if (repo != null) { return(RedirectToAction("Tree", "Repository", new { owner = model.Owner, name = repo.Name })); } } catch (ArgumentException ex) { //ModelState.AddModelError(ex.ParamName, SR.Repository_AlreadyExists); ModelState.AddModelError(ex.ParamName, ex.Message); } catch (Exception ex) { ModelState.AddModelError("", ex); } } return(CreateView(model)); }
public async Task <ActionResult <bool> > PostFloodData([FromBody] FloodData floodData) { if (!ModelState.IsValid) { loggerFactory.LogError("Bad flood data sent in request"); return(BadRequest(floodData)); } else { loggerFactory.LogError("Successfully saved flood data"); floodData.Created = DateTime.Now; var response = repositoryService.Create(floodData); } return(true); }