Example #1
0
        public bool create(Photo photo)
        {
            using (PhotoDBEntities pdbe = new PhotoDBEntities())
            {
                try
                {
                    PhotoEntity pe = new PhotoEntity();

                    pe.Title = photo.Title;
                    pe.Image = photo.Image;
                    pe.UserName = photo.UserName;
                    pe.AddDate=photo.AddDate;
                    pe.Model=photo.Model;
                    pe.Resolution=photo.Resolution;
                    pe.Explosure=photo.Explosure;
                    pe.CreateDate=photo.CreateDate;
                    pe.Rating = photo.Rating;
                    pe.NumderVote = photo.NumderVote;

                    pdbe.PhotoEntities.Add(pe);
                    pdbe.SaveChanges();
                    return true;
                }
                catch
                {
                    return false;
                }
            };
        }
Example #2
0
 public bool edit(Photo photo)
 {
     using (PhotoDBEntities pdbe = new PhotoDBEntities())
     {
         try
         {
             PhotoEntity pe = pdbe.PhotoEntities.Single(p => p.Id == photo.Id);
             pe.Title = photo.Title;
             pdbe.SaveChanges();
             return true;
         }
         catch
         {
             return false;
         }
     }
 }
Example #3
0
 public bool delete(Photo photo)
 {
     using (PhotoDBEntities pdbe = new PhotoDBEntities())
     {
         try
         {
             PhotoEntity pe = pdbe.PhotoEntities.Single(p => p.Id == photo.Id);
             pdbe.PhotoEntities.Remove(pe);
             pdbe.SaveChanges();
             return true;
         }
         catch
         {
             return false;
         }
     }
 }