コード例 #1
0
        public string DeleteProject(int id)
        {
            Tbl_Projects tbl_Projects = new Tbl_Projects {
                Id = id
            };
            BlogEntities1 blog = new BlogEntities1();

            blog.Entry(tbl_Projects).State = EntityState.Deleted;
            blog.SaveChanges();
            return("deleted");
        }
コード例 #2
0
 public string AddProject(string name, string desc, int cId, HttpPostedFileBase file)
 {
     if (name != null && desc != null && cId > 0 && file != null)
     {
         var relativePath = Guid.NewGuid() + "-" + file.FileName;
         var path         = Server.MapPath("~/Photo/" + relativePath);
         file.SaveAs(path);
         Tbl_Projects project = new Tbl_Projects
         {
             CategoryId  = cId,
             Description = desc,
             P_Name      = name,
             Image       = relativePath
         };
         blogEntities.Tbl_Projects.Add(project);
         blogEntities.SaveChanges();
         return("created");
     }
     return("fail");
 }