public IHttpActionResult Post(GenreCreate model) { if (!ModelState.IsValid) { return(BadRequest()); } if (!_service.CreateGenre(model)) { return(InternalServerError()); } return(Ok("Genre created successfully!")); }
public bool CreateGenre(GenreCreate model) { var entity = new Genre() { GenreName = model.GenreName }; using (var ctx = new ApplicationDbContext()) { ctx.Genres.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateGenre(GenreCreate model) { var entity = new Genre() { Name = model.Name, Description = model.Description, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Genres.Add(entity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(GenreCreate genre) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateGenreService(); if (!service.CreateGenre(genre)) { return(InternalServerError()); } return(Ok()); }
public bool CreateGenre(GenreCreate model) { var entity = new Genre() { GameGenreId = model.GameGenreId, GenreName = model.GenreName, GameID = model.ID, GameTitle = model.GameTitle }; using (var ctx = new GameFinderDbContext()) { ctx.Genres.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateGenre(GenreCreate model) { var entity = new Genre() { OwnerId = _userId, Type = model.Type, Description = model.Description, //AlbumId = model.AlbumId, //SongId = model.SongId }; using (var ctx = new ApplicationDbContext()) { ctx.Genres.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(GenreCreate model) { if (!ModelState.IsValid) { return(View(model)); } var _service = CreateGenreService(); if (_service.CreateGenre(model)) { TempData["SaveResult"] = "Your Genre was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Your Genre could not be created."); return(View(model)); }