public IHttpActionResult Post(StadiumCreate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } StadiumService service = CreateStadiumService(); if (service.CreateStadium(model)) { return(Ok()); } return(InternalServerError()); }
public bool CreateStadium(StadiumCreate model) { var entity = new StadiumEntity { StadiumName = model.StadiumName, CityName = model.CityName, StateName = model.StateName, OwnerID = _userID }; using (var ctx = new ApplicationDbContext()) { ctx.Stadiums.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateStadium(StadiumCreate model) { var entity = new Stadium() { OwnerId = _userId, Name = model.Name, Location = model.Location, Capacity = model.Capacity }; using (var ctx = new ApplicationDbContext()) { ctx.Stadium.Add(entity); return(ctx.SaveChanges() == 1); } }