示例#1
0
 /// <summary>
 /// Create a new ListingMedia object.
 /// </summary>
 /// <param name="listingMediaId">Initial value of the ListingMediaId property.</param>
 /// <param name="listingId">Initial value of the ListingId property.</param>
 /// <param name="fileId">Initial value of the FileId property.</param>
 /// <param name="createdOn">Initial value of the CreatedOn property.</param>
 /// <param name="updatedOn">Initial value of the UpdatedOn property.</param>
 /// <param name="createdBy">Initial value of the CreatedBy property.</param>
 /// <param name="updatedBy">Initial value of the UpdatedBy property.</param>
 /// <param name="isActive">Initial value of the IsActive property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static ListingMedia CreateListingMedia(global::System.Int64 listingMediaId, global::System.Int64 listingId, global::System.Int64 fileId, global::System.DateTime createdOn, global::System.DateTime updatedOn, global::System.Int64 createdBy, global::System.Int64 updatedBy, global::System.Boolean isActive, global::System.Boolean isDeleted)
 {
     ListingMedia listingMedia = new ListingMedia();
     listingMedia.ListingMediaId = listingMediaId;
     listingMedia.ListingId = listingId;
     listingMedia.FileId = fileId;
     listingMedia.CreatedOn = createdOn;
     listingMedia.UpdatedOn = updatedOn;
     listingMedia.CreatedBy = createdBy;
     listingMedia.UpdatedBy = updatedBy;
     listingMedia.IsActive = isActive;
     listingMedia.IsDeleted = isDeleted;
     return listingMedia;
 }
示例#2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ListingMedia EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToListingMedia(ListingMedia listingMedia)
 {
     base.AddObject("ListingMedia", listingMedia);
 }
示例#3
0
        public IMediaDTO CreateListingMedia(IFileDTO fileDto)
        {
            IMediaDTO mediaDto = (IMediaDTO)DTOFactory.Instance.Create(DTOType.Media);
            try
            {
                if (fileDto != null)
                {
                    using (TransactionScope trans = new TransactionScope())
                    {
                        using (var TMCDbContext = new TMCContext())
                        {
                            var fileEntity = new File();
                            //EntityConverter.FillEntityFromDTO(fileDto, fileEntity);
                            fileEntity.CreatedOn = DateTime.Now;
                            fileEntity.CreatedBy = 11;
                            fileEntity.UpdatedOn = DateTime.Now;
                            fileEntity.UpdatedBy = 11;
                            fileEntity.IsActive = true;
                            fileEntity.IsDeleted = false;
                            fileEntity.FileTitle = fileDto.FileTitle;
                            fileEntity.OriginalFileName = fileDto.OriginalFileName;
                            fileEntity.ServerFileName = fileDto.ServerFileName;
                            fileEntity.ServerPath = fileDto.ServerPath;
                            fileEntity.FileExtensionId = fileDto.FileExtensionId;
                            fileEntity.FileTypeId = fileDto.FileTypeId;
                            TMCDbContext.File.AddObject(fileEntity);
                            if (TMCDbContext.SaveChanges() > 0)
                            {
                                fileDto.FileId = fileEntity.FileId;
                                var listingMediaEntity = new ListingMedia();
                                //EntityConverter.FillEntityFromDTO(fileDto, fileEntity);//todo do later
                                listingMediaEntity.CreatedOn = DateTime.Now;
                                listingMediaEntity.CreatedBy = 11;
                                listingMediaEntity.UpdatedOn = DateTime.Now;
                                listingMediaEntity.UpdatedBy = 11;
                                listingMediaEntity.IsActive = true;
                                listingMediaEntity.IsDeleted = false;
                                listingMediaEntity.ListingId = fileDto.ListingId;
                                listingMediaEntity.FileId = fileDto.FileId;
                                TMCDbContext.ListingMedia.AddObject(listingMediaEntity);
                                if (TMCDbContext.SaveChanges() > 0)
                                {
                                    mediaDto.ListingMediaId = listingMediaEntity.ListingMediaId;
                                    mediaDto.FileId = listingMediaEntity.FileId;
                                    mediaDto.FileName = fileDto.OriginalFileName;
                                    mediaDto.ServerFileName = fileDto.ServerFileName;

                                }
                            }
                        }
                        trans.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException("Error while creating the listing detail.", ex);
            }
            return mediaDto;
        }