/// <summary> /// Shows cards from Rewardo in specified package /// </summary> /// <param name="id"></param> /// <param name="packageId"></param> /// REQ002; PARTNER; public ActionResult ShowCardsInPackage(long id, uint packageId) { cardOrderEngine = new CardOrderEngine(); List <string> tablesToInit = new List <string>() { "CardOrderRequests", "CardOrderAnswers", "partners" }; cardOrderEngine.setDbTableInitialization("all", tablesToInit); // get card order partner name var partnerName = cardOrderEngine.getCardnetDAL().getPartnerNameByOrderId(id); // get organization ID from REWARDO.ORGANIZATION table according to @param partnerName == ORGANIZATION.NAME == ___PARTNER.ORGANIZATION_NAME var organizationID = cardOrderEngine.getRewardoEngine().getOrganizationId(partnerName); // get card order XML var pomXelement = cardOrderEngine.getCardnetDAL().getXMLByOrderId(id); var partnerCardIdsFromRW = cardOrderEngine.getRewardoEngine().getPartnerCardIdsFromRW(partnerName); // from RW var partnerCardsFromCNXML = cardOrderEngine.getCardnetDAL().getCardsFromXMLByPartnerAndPackageIdFromCN(id, packageId); // from CN var cardsNotInRW = new List <long>(); var pomRewardoCardListViewModel = cardOrderEngine.getRewardoEngine().getRewardoCardListViewModel(); var pom1 = new RewardoCardListViewModel(); cardOrderEngine.getRewardoEngine().createRewardoCardListViewModel(partnerCardsFromCNXML, pom1, pomRewardoCardListViewModel, organizationID); pom1.orderId = id; pom1.packageId = packageId; pom1.rclvm.OrderBy(rcl => rcl.OrderInPackage); int pomocnaPremenna = 0; // better to use DO-WHILE foreach (var i in pom1.rclvm) { if (i.Cardno == "") { pomocnaPremenna += 1; } } if (pomocnaPremenna != 0) { pom1.infoColor = "red"; pom1.info = "Uncompleted order in Rewardo. Some (or all) cards are not still in Rewardo."; return(View("ShowCardsInPackage", pom1)); } else { pom1.infoColor = "green"; pom1.info = "Cards are succesfully created in Rewardo."; return(View("ShowCardsInPackage", pom1)); } }
/// <summary> /// returns t/f value. If <param>pomRewardoCardListViewModel</param> includes <param>item</param> => return true else return false /// </summary> /// <param name="pomRewardoCardListViewModel"></param> /// <param name="item"></param> /// <param name="organizationId">Organization ID</param> /// <returns></returns> private bool rewardoCardListViewModelContainsThisCardId(RewardoCardListViewModel pomRewardoCardListViewModel, long item, short organizationId) { var result = false; var pomRclvm = pomRewardoCardListViewModel.rclvm.Where(o => o.OrganizationId == organizationId).ToList(); if (pomRclvm.Any()) { var i = 0; do { result = pomRclvm[i].CardCRMId == item ? true : false; i++; } while (i < pomRclvm.Count && result == false); } return(result); }
/// <summary> /// /// </summary> /// <param name="partnerCardsFromCNXML">All cards of specific partner in XML</param> /// <param name="pom">out var</param> /// <param name="pomRewardoCardListViewModel">All cards of specific partner in REWARDO</param> /// <param name="organizationID">Organization ID</param> public void createRewardoCardListViewModel(List <long> partnerCardsFromCNXML, RewardoCardListViewModel pom, RewardoCardListViewModel pomRewardoCardListViewModel, short organizationId) { foreach (var item in partnerCardsFromCNXML) { if (rewardoCardListViewModelContainsThisCardId(pomRewardoCardListViewModel, item, organizationId)) // if does not contain { var rewardoCardViewModel = getRewardoCardViewModelByCardCrmId(item, organizationId); pom.rclvm.Add(rewardoCardViewModel); } else { // Create foo RewardoCardViewModel with CARDNO == "" and add to @param pom RewardoCardViewModel rewardoCardViewModel = new RewardoCardViewModel(); rewardoCardViewModel.CardCRMId = item; rewardoCardViewModel.Cardno = ""; pom.rclvm.Add(rewardoCardViewModel); } } }
public RewardoEngine() { m_RewardoDAL = new RewardoDAL(); m_rewardoCLVM = new RewardoCardListViewModel(); retrieveRewardoCardViewModel(); }