//returning list of shareinterstes taking into account the current price of share public ICollection <InterestedShareModel> GetInfoInterestedShare(InterestedShareQuery interestInfo) { ICollection <InterestedShareModel> list = db.InterestedShares.Where(c => (c.ShareId == interestInfo.ShareId && (interestInfo.ActualPrice > c.MaxPrice || interestInfo.ActualPrice < c.MinPrice))).ToList(); db.SaveChanges(); return(list); }
//outside methods towards clients //passing the shareid that was modified. Check which user is interested and notify it public void NotifyShareChanges(ShareModel shareModified) { //debug InterestedShareQuery shareQuery = new InterestedShareQuery { ShareId = shareModified.Id, ActualPrice = shareModified.Price }; ShareOutViewModel outViewShare = new ShareOutViewModel(shareModified); ICollection <InterestedShareModel> usersToNotify = _repository.GetInfoInterestedShare(shareQuery); foreach (InterestedShareModel shareModel in usersToNotify) { Clients.User(shareModel.UserId).receiveStockMessage("the share you are interested " + shareModel.ShareId + " has moved price into your interest"); } UpdateShares(outViewShare); }