public bool AddPhotoToAlbum(string fileName, String originalFileName, Guid albumId)
        {
            Model.PhotoAlbumEntities context = ContextManager.GetCurrent();
            Model.PhotoAlbum         album   = (Model.PhotoAlbum)context.GetObjectByKey(
                context.CreateKeyFor <Model.PhotoAlbum>(albumId));
            Photo photo = PhotoPostProcessor.ProcessPhoto(fileName, originalFileName);

            photo.PhotoAlbum = album;
            album.Photo.Load();
            photo.PhotoIndex = album.Photo.Count();
            context.AddToPhoto(photo);
            return(context.SaveChanges() > 0);
        }
        public Model.PhotoAlbum GetPhotoAlbumWithPhoto(Guid albumId)
        {
            Model.PhotoAlbumEntities context = ContextManager.GetCurrent();
            Object entity;

            if (!context.TryGetObjectByKey(context.CreateKeyFor <Model.PhotoAlbum>(albumId), out entity))
            {
                return(null);
            }

            Model.PhotoAlbum album = (Model.PhotoAlbum)entity;
            album.Photo.Load();
            album.Photo.ReorderEntities(p => p.PhotoIndex);
            return(album);
        }
Exemple #3
0
 protected void btnAddNewElement_Click(object sender, EventArgs e)
 {
     Model.PhotoAlbum album = new Model.PhotoAlbum()
     {
         CreationDate = DateTime.Now,
         Description  = txtdescriptionForNewElement.Text,
         Name         = txtNameForNewElement.Text,
         Users        = Services.SecurityService.GetUserFromUserId(
             UserHelper.GetIdOfCurrentUser())
     };
     if (Services.PhotoManagerService.CreateOrUpdatePhotoAlbum(album))
     {
         grdPhotoAlbum.DataBind();
         txtNameForNewElement.Text        = "";
         txtdescriptionForNewElement.Text = "";
     }
 }
 protected void btnAddNewElement_Click(object sender, EventArgs e)
 {
     Model.PhotoAlbum album = new Model.PhotoAlbum()
                              {
                                 CreationDate = DateTime.Now,
                                 Description = txtdescriptionForNewElement.Text,
                                 Name = txtNameForNewElement.Text,
                                 Users = Services.SecurityService.GetUserFromUserId(
                                   UserHelper.GetIdOfCurrentUser())
                              };
      if (Services.PhotoManagerService.CreateOrUpdatePhotoAlbum(album))
      {
     grdPhotoAlbum.DataBind();
     txtNameForNewElement.Text = "";
     txtdescriptionForNewElement.Text = "";
      }
 }
        public Boolean CreateOrUpdatePhotoAlbum(Model.PhotoAlbum album)
        {
            Model.PhotoAlbumEntities context = ContextManager.GetCurrent();

            if (album.EntityState == EntityState.Added)
            {
                context.AddToPhotoAlbum(album);
            }
            else
            {
                if (album.EntityKey == null)
                {
                    album.EntityKey = context.CreateKeyFor <Model.PhotoAlbum>(album.Id);
                }
                context.Attach(album);
            }

            return(context.SaveChanges() > 0);
        }
 public bool CreateOrUpdatePhotoAlbum(Model.PhotoAlbum album)
 {
     return(PhotoManagerService.CreateOrUpdatePhotoAlbum(album));
 }
Exemple #7
0
 public Boolean Update(Model.PhotoAlbum album)
 {
     return(Services.PhotoManagerService.CreateOrUpdatePhotoAlbum(album));
 }
 public static bool CreateOrUpdatePhotoAlbum(Model.PhotoAlbum album)
 {
     return(instance.CreateOrUpdatePhotoAlbum(album));
 }