예제 #1
0
        // 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));
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblArtist tblArtist = db.tblArtist.Find(id);

            db.tblArtist.Remove(tblArtist);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
 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));
 }
예제 #4
0
        public IHttpActionResult GettblArtist(int id)
        {
            tblArtist tblartist = db.tblArtists.Find(id);

            if (tblartist == null)
            {
                return(NotFound());
            }

            return(Ok(tblartist));
        }
예제 #5
0
        public ActionResult Create([Bind(Include = "ArtistID,ArtistName")] tblArtist tblArtist)
        {
            if (ModelState.IsValid)
            {
                db.tblArtist.Add(tblArtist);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tblArtist));
        }
예제 #6
0
        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));
     }
 }
예제 #8
0
        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));
        }
예제 #9
0
        // 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));
        }
예제 #10
0
        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());
            }
        }
예제 #11
0
        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());
        }
예제 #12
0
 public DeleteViewModel(tblArtist artist, List <tblRecord> records)
 {
     Artist      = artist;
     RecordsList = records.Where(x => x.ArtistID == Artist.ArtistID).ToList();
 }
예제 #13
0
 public DetailsViewModel(tblArtist artist, List <tblRecord> recordslist)
 {
     Artist      = artist;
     RecordsList = recordslist.Where(x => x.ArtistID == Artist.ArtistID).ToList();
 }