// PUT api/Artist/5 public IHttpActionResult PuttblArtist(int id, tblArtist tblartist) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblartist.Artist_id) { return(BadRequest()); } db.Entry(tblartist).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tblArtistExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { tblArtist tblArtist = db.tblArtist.Find(id); db.tblArtist.Remove(tblArtist); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ArtistID,ArtistName")] tblArtist tblArtist) { if (ModelState.IsValid) { db.Entry(tblArtist).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblArtist)); }
public IHttpActionResult GettblArtist(int id) { tblArtist tblartist = db.tblArtists.Find(id); if (tblartist == null) { return(NotFound()); } return(Ok(tblartist)); }
public ActionResult Create([Bind(Include = "ArtistID,ArtistName")] tblArtist tblArtist) { if (ModelState.IsValid) { db.tblArtist.Add(tblArtist); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblArtist)); }
public IHttpActionResult PosttblArtist(tblArtist tblartist) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tblArtists.Add(tblartist); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tblartist.Artist_id }, tblartist)); }
public ActionResult Edit([Bind(Include = "ArtistID, ArtistName, ArtistBio, ImageSrc, ImageAlt")] tblArtist artist) { if (ModelState.IsValid) { context.Entry(artist).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("AdminIndex")); } else { return(View(artist)); } }
public IHttpActionResult DeletetblArtist(int id) { tblArtist tblartist = db.tblArtists.Find(id); if (tblartist == null) { return(NotFound()); } db.tblArtists.Remove(tblartist); db.SaveChanges(); return(Ok(tblartist)); }
// GET: Artists/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblArtist tblArtist = db.tblArtist.Find(id); if (tblArtist == null) { return(HttpNotFound()); } return(View(tblArtist)); }
public ActionResult Create(CreateViewModel createvm) { if (ModelState.IsValid) { string filename = Path.GetFileName(createvm.Image.FileName); createvm.ImageSrc = "~/Content/ArtistImages/" + filename; filename = Path.Combine(Server.MapPath("~/Content/ArtistImages/"), filename); createvm.Image.SaveAs(filename); tblArtist artist = new tblArtist(createvm.ArtistName, createvm.ArtistBio, createvm.ImageSrc, createvm.ImageAlt); context.tblArtists.Add(artist); context.SaveChanges(); ModelState.Clear(); return(View()); } else { return(View()); } }
public ActionResult Delete(DeleteViewModel view) { bool isPasswordValid = context.tblUsers .Any(x => x.UserName.ToLower() == User.Identity.Name.ToLower() && x.Password == view.Password); if (isPasswordValid) { tblArtist artist = context.tblArtists.Find(view.Artist.ArtistID); List <tblRecord> records = context.tblRecords.Where(x => x.ArtistID == artist.ArtistID).ToList(); foreach (var item in records) { context.tblRecords.Remove(item); } context.tblArtists.Remove(artist); context.SaveChanges(); return(RedirectToAction("AdminIndex")); } return(View()); }
public DeleteViewModel(tblArtist artist, List <tblRecord> records) { Artist = artist; RecordsList = records.Where(x => x.ArtistID == Artist.ArtistID).ToList(); }
public DetailsViewModel(tblArtist artist, List <tblRecord> recordslist) { Artist = artist; RecordsList = recordslist.Where(x => x.ArtistID == Artist.ArtistID).ToList(); }