Exemplo n.º 1
0
 /// <summary>
 /// Add new image to database
 /// </summary>
 /// <param name="image"></param>
 /// <returns></returns>
 public int?AddImage(Model.Context.share_Images image)
 {
     try
     {
         image.Status = (int)Define.Status.Active;
         imageRepository.Insert(image);
         imageRepository.Save();
         return(image.Id);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Add image for exist project
        /// </summary>
        /// <param name="ProjectId">project id</param>
        /// <param name="photo">new image</param>
        /// <param name="listImages"> return list image after adding finish</param>
        /// <returns>return true if action is success or false action is fail</returns>
        public bool AddImageForProject(int projectId, Model.Context.share_Images photo)
        {
            portal_Projects project = db.GetProjectById(projectId);

            if (project == null)
            {
                return(false);
            }
            else
            {
                project.share_Images.Add(photo);
                db.Save();
                return(true);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Delete image in project
 /// </summary>
 /// <param name="projectId">project id</param>
 /// <param name="imageId">id of image need to delete</param>
 /// <param name="listImages">list images of project after do action</param>
 /// <param name="imagePath">path of deteled image(using for delete image in folder)</param>
 /// <returns>return true if action is success or false if action is fail</returns>
 public bool DeleteImage(int projectId, int imageId, out Model.Context.share_Images deleteImages)
 {
     try
     {
         portal_Projects project = GetProjectById(projectId);
         share_Images    image   = project.share_Images.Where(i => i.Id == imageId).SingleOrDefault();
         deleteImages = image;
         //Delete image in product
         project.share_Images.Remove(image);
         db.Save();
         // Delete image in table share_images
         var deleteImage = imageRepository.GetByID(imageId);
         imageRepository.Delete(deleteImage);
         imageRepository.Save();
         return(true);
     }
     catch (Exception)
     {
         deleteImages = null;
         return(false);
     }
 }