public ActionResult Create(Category category) { try { // TODO: Add insert logic here /* if(string.IsNullOrEmpty(category.CategoryName) || * string.IsNullOrEmpty(category.Description)) * { * ModelState.AddModelError("CategoryName","Field is Required."); * return View(model: category); * } * else * { * ModelState.AddModelError("CategoryName", ""); //Removes the message * }*/ if (ModelState.IsValid) { repository.CreateNew(item: category); return(RedirectToAction("Index")); } else { return(View(model: category)); } repository.CreateNew(item: category); return(RedirectToAction("Index")); } catch { return(View(model: category)); } }
public override FileLink SaveFile(IRepository repository) { var id = repository.CreateNew(Name); var link = new FileLink { Id = id }; Link = link; return link; }
public async Task <StartGameResponse> Handle(StartGameRequest request, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); try { var utc = DateTimeOffset.UtcNow; var newGame = new GameEntity(); newGame.Board = new string[3, 3]; for (var i = 0; i <= 2; i++) { for (var j = 0; j <= 2; j++) { newGame.Board[i, j] = string.Empty; } } newGame.Id = ToShortGuid(Guid.NewGuid()); newGame.CreatedUtc = utc; newGame.LastUpdatedUtc = utc; newGame.Status = GameKnownStatuses.InProgress; newGame.WaitingForPlayer = GameKnownWaitingForPlayer.WaitingForPlayer1; newGame.Result = GameKnownResults.InProgress; await _repo.CreateNew(newGame, cancellationToken); return(new StartGameResponse { Created = newGame }); } catch (Exception ex) { _logger.LogError(ex, "Unexpected exception"); throw; } }
public ActionResult Create(Category category) { try { // TODO: Add insert logic here //if (string.IsNullOrEmpty(category.CategoryName)) //{ // ModelState.AddModelError("CategoryName", "Field is required"); // return View(model: category); //} //else //{ // ModelState.AddModelError("CategoryName", ""); //} //if (string.IsNullOrEmpty(category.Description)) //{ // ModelState.AddModelError("Description", "Field is required"); // return View(model: category); //} //else //{ // ModelState.AddModelError("Description", ""); //} if (ModelState.IsValid) { repository.CreateNew(item: category); return(RedirectToAction("Index")); } else { return(View(model: category)); } } catch { return(View(model: category)); } }
public ActionResult Create(Customer model) { repository.CreateNew(model); return(RedirectToAction("Index")); }
protected override FileLink SaveFilePerform(IRepository repository) { var id = repository.CreateNew(Name); var link = new FileLink { Id = id, Metadata = Metadata }; return link; }
internal TerrainMK2 NewMockTerrain() { return(repo.CreateNew()); }