public IActionResult SaveNew(NewStageVM Model) { if (!ModelState.IsValid) { Model.Sponsors = _repo.GetAllSponsors().Select(s => new SelectListItem { Text = s.CompanyName, Value = s.ID.ToString(), }).ToList(); return(View("New", Model)); } string uniqueFileName = Image.Upload(Model.Image, _hostingEnvironment, "stages"); Stage stage = new Stage(); stage.Name = Model.Name; stage.Capacity = Model.Capacity; stage.SponsorID = Model.SponsorID; stage.Image = uniqueFileName; _repo.Add(stage); return(RedirectToAction("List")); }
public async Task <IActionResult> Post([FromBody] NewStageRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = new Stage() { Title = request.Title, Order = request.Order }; try { await _repository.Add(entity); } catch (Exception ex) { _logger.LogError(Guid.NewGuid().ToString(), ex); } return(Created(Url.RouteUrl(entity.Id), ConvertResponse(entity))); }
public ActionResult Post([FromBody] Stage stage) { sr.Add(stage); return(Ok()); }