public bool CreatePublisher(PublisherCreate model) { var entity = new Publisher() { PublisherName = model.PublisherName, Address = model.Address, PublisherWebsite = model.PublisherWebsite }; using (var ctx = new ApplicationDbContext()) { ctx.Publishers.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreatePublisher(PublisherCreate model) { var entity = new Publisher() { Name = model.Name, CompanySize = model.CompanySize, Country = model.Country, Rating = -1, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Publishers.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(PublisherCreate model) { if (!ModelState.IsValid) { return(View(model)); } // var service = new PublisherService(); if (_publisherService.CreatePublisher(model)) { TempData["SaveResult"] = "Your publisher was added."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Publisher could not be added."); return(View(model)); }