public IHttpActionResult Delete(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Id Not found"));
            }

            using (var db = new MyPortfolioEntities())
            {
                var data = db.skills.Where(x => x.id_skill == id).FirstOrDefault();

                db.Entry(data).State = System.Data.Entity.EntityState.Deleted;
                db.SaveChanges();
            }
            return(Ok());
        }
Beispiel #2
0
        public IHttpActionResult Delete(int Id)
        {
            MyPortfolioEntities db = new MyPortfolioEntities();
            var porto = db.portfolios.Find(Id);

            string image = HttpContext.Current.Request.MapPath(porto.image_path);

            db.Entry(porto).State = System.Data.Entity.EntityState.Deleted;

            if (db.SaveChanges() > 0)
            {
                if (System.IO.File.Exists(image))
                {
                    System.IO.File.Delete(image);
                }
                return(Ok());
            }

            return(Ok());
        }
        public IHttpActionResult Delete(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Fail delete category"));
            }

            using (db)
            {
                var data = db.categorys.Where(x => x.id_category == id).FirstOrDefault();
                if (data != null)
                {
                    db.Entry(data).State = System.Data.Entity.EntityState.Deleted;
                    db.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }

            return(Ok());
        }