Exemple #1
0
        internal static void EnsureBlogImageExists(String blogImageGuid, out BlogImageLINQ blogImageLinq, String message, MinimaServiceLINQDataContext db)
        {
            Func <BlogImageLINQ, Boolean> blogImageExists = x => x.BlogImageGuid == blogImageGuid;

            blogImageLinq = db.BlogImages.SingleOrDefault(blogImageExists);
            if (blogImageLinq == null)
            {
                throw new ArgumentException(message);
            }
        }
Exemple #2
0
 public String SaveImage(BlogImage blogImage, String blogGuid)
 {
     using (DataContext db = new DataContext(ServiceConfiguration.ConnectionString))
     {
         //+ ensure blog exists
         BlogLINQ blogLinq;
         Validator.EnsureBlogExists(blogGuid, out blogLinq, db);
         Validator.EnsureIsNotNull(blogImage.Data, Message.ImageDataNull);
         Validator.IsNotBlank(blogImage.ContentType, Message.ContentTypeBlank);
         //+
         Binary        imageBinary   = new Binary(blogImage.Data);
         BlogImageLINQ blogImageLinq = new BlogImageLINQ();
         blogImageLinq.BlogId = blogLinq.BlogId;
         blogImageLinq.BlogImageContentType = blogImage.ContentType;
         blogImageLinq.BlogImageData        = imageBinary;
         blogImageLinq.BlogImageGuid        = Themelia.GuidCreator.GetNewGuid();
         //+
         db.BlogImages.InsertOnSubmit(blogImageLinq);
         db.SubmitChanges();
         //+
         return(blogImageLinq.BlogImageGuid);
     }
 }
Exemple #3
0
 //- ~EnsureBlogImageExists -//
 internal static void EnsureBlogImageExists(String blogImageGuid, out BlogImageLINQ blogImageLinq, MinimaServiceLINQDataContext db)
 {
     EnsureBlogImageExists(blogImageGuid, out blogImageLinq, Message.InvalidImageGuid, db);
 }