Esempio n. 1
0
 /// <summary>
 /// Deletes a media object from the context
 /// </summary>
 /// <param name="media"></param>
 public void DeleteMedia(Media media)
 {
     GetUnitOfWork.Medias.DeleteObject(media);
 }
Esempio n. 2
0
 /// <summary>
 /// Adds a new media file record to the context
 /// </summary>
 /// <param name="contentLength"></param>
 /// <param name="contentType"></param>
 /// <param name="fileName"></param>
 public void AddNewMedia(int contentLength, string contentType, string fileName, string fullPath)
 {
     // get mime type from database
     MimeType mime = GetUnitOfWork.MimeTypes.Where(x => x.Name == contentType).Single();
     // create media record
     Media media = new Media
                       {
                           FileName = fileName,
                           Extension = Path.GetExtension(fileName),
                           MimeType = mime,
                           Path = fullPath,
                           UploadDate = DateTime.Now
                      };
     // add to context
     GetUnitOfWork.Medias.AddObject(media);
 }