public static SharedFile ToOrmSharedFile(this DalSharedFile sharedFileEntity) { return(new SharedFile() { FileId = sharedFileEntity.FileId, OwnerId = sharedFileEntity.OwnerId, RecipientId = sharedFileEntity.RecipientId }); }
/// <summary> /// Mapping <see cref="DalSharedFile"/> entity to <see cref="BllSharedFile"/> entity. /// </summary> public static BllSharedFile ToBllSharedFileFile(this DalSharedFile sharedFileEntity) { return(new BllSharedFile() { OwnerId = sharedFileEntity.OwnerId, RecipientId = sharedFileEntity.RecipientId, FileId = sharedFileEntity.FileId }); }
public void Create(DalSharedFile entity) { var ormSharedFile = entity?.ToOrmSharedFile(); if (ormSharedFile == null) { return; } Context.Set <SharedFile>()?.Add(ormSharedFile); }
public DalSharedFile Get(DalSharedFile entity) { var sharedFile = Context.Set <SharedFile>()? .FirstOrDefault( sf => sf.FileId == entity.FileId && sf.OwnerId == entity.OwnerId && sf.RecipientId == entity.RecipientId); return(sharedFile?.ToDalSharedFile()); }
public void Delete(DalSharedFile entity) { var ormSharedFile = Context.Set <SharedFile>()? .FirstOrDefault( sf => sf.FileId == entity.FileId && sf.OwnerId == entity.OwnerId && sf.RecipientId == entity.RecipientId); if (ormSharedFile == null) { return; } Context.Set <SharedFile>()?.Remove(ormSharedFile); }
public void CreateSharedFile(int ownerId, int recipientId, int fileId) { var sharedFile = new DalSharedFile() { FileId = fileId, OwnerId = ownerId, RecipientId = recipientId }; UnitOfWork.SharedFileRepository.Create(sharedFile); UnitOfWork.Commit(); var sharedFileFromDb = UnitOfWork.SharedFileRepository.GetAll() .FirstOrDefault( sf => sf.FileId == sharedFile.FileId && sf.RecipientId == recipientId && sf.OwnerId == ownerId); Assert.AreEqual(sharedFileFromDb?.OwnerId, ownerId); }
public void Update(DalSharedFile entity) { throw new NotImplementedException(); }