public void Delete(DalFriend entity) { if (entity == null) { return; } Delete(entity.Id); }
/// <summary> /// Mapping <see cref="DalFriend"/> entity to <see cref="BllFriend"/> entity. /// </summary> public static BllFriend ToBllFriend(this DalFriend friendEntity) { return(new BllFriend() { Id = friendEntity.Id, FriendId = friendEntity.FriendId, UserId = friendEntity.UserId }); }
public void Create(DalFriend entity) { var ormFriend = entity?.ToOrmFriend(); if (ormFriend == null) { return; } Context.Set <Friend>()?.Add(ormFriend); }
public void CreateFriendship(int userId, int friendId) { var friendship = new DalFriend() { FriendId = friendId, UserId = userId }; UnitOfWork.FriendRepository.Create(friendship); UnitOfWork.Commit(); var friendshipFromDb = UnitOfWork.FriendRepository.GetAll() .FirstOrDefault(fs => fs.UserId == userId && fs.FriendId == friendId); Assert.AreEqual(friendshipFromDb.FriendId, friendId); }
public void Update(DalFriend entity) { if (entity == null) { return; } var ormFriend = Context.Set <Friend>()? .FirstOrDefault(fr => fr.Id == entity.Id); if (ormFriend == null) { return; } ormFriend.Id = entity.Id; ormFriend.FriendId = entity.FriendId; ormFriend.UserId = entity.UserId; }