public ActionResult AddBatchCards(ReceiveAndShipCardModel WebPageData) { String ErrorCode = ""; String BadCard = ""; String AgentUserName = (String)Session["AgentUserName"]; if (AgentUserName == null) { AgentUserName = User.Identity.Name; } if (AgentUserName.Length == 0) { AgentUserName = User.Identity.Name; } try { if (!VerifyNotDuplicateCard(WebPageData.BatchCards, out BadCard)) { ModelState.AddModelError("BatchCards", "Card " + BadCard + " is a duplicate"); } if (ModelState.IsValid) { // Attempt to add the card String CardBatch = WebPageData.BatchCards; String MultiStoreCode = WebPageData.MultiStoreCode; if (WebPageData.BatchCards != null) { ErrorCode = CardServiceInstance.AddAndShipBatch(WebPageData.MerchantName, CardBatch); } if (ErrorCode == "APP ") { ModelState.AddModelError("", "Card(s) Received into Inventory"); } else { ModelState.AddModelError("", "Failed to add the cards: " + Utility.ConvertErrorCodes(ErrorCode)); } } } catch (Exception Ex) { ModelState.AddModelError("", Common.StandardExceptionErrorMessage(Ex)); } // rebuild the merchant list WebPageData.MerchantList = MerchantServiceInstance.GetMerchantsForSelect( AgentUserName, Roles.IsUserInRole(AgentUserName, "Agent")); return(View(WebPageData)); }
private bool VerifyNotDuplicateCard(String CardList, out String BadCard) { BadCard = ""; String[] Cards = CardList.Split('\n'); foreach (String Crd in Cards) { BadCard = Crd; if (CardServiceInstance.Getcard(Crd) != null) { return(false); } } return(true); }
public ActionResult ShipCards(ShipCards WebPageData, string returnUrl) { String ErrorCode; if (ModelState.IsValid) { // Attempt to add the card String CardToShip = WebPageData.FirstCardNumber; String ClerkID = ""; String MerchantID = WebPageData.MerchantName; String TransactionText = "Shipping Cards"; if (WebPageData.NumberOfCards != null) { Int32 CountToShip = Convert.ToInt32(WebPageData.NumberOfCards); ErrorCode = CardServiceInstance.ShipCards(MerchantID, ClerkID, CardToShip, CountToShip, TransactionText); } else { if (WebPageData.LastCardNumber != null) { String LastCardToShip = WebPageData.LastCardNumber; ErrorCode = CardServiceInstance.ShipCards(MerchantID, ClerkID, CardToShip, LastCardToShip, TransactionText); } else { ErrorCode = "Nothing To Ship"; } } if (ErrorCode == "APP ") { ModelState.AddModelError("", "Cards shipped to " + MerchantID); } else { ModelState.AddModelError("", "Failed to ship the cards " + Utility.ConvertErrorCodes(ErrorCode)); } } // rebuild the merchant list WebPageData.MerchantList = MerchantServiceInstance.GetMerchantsForSelect("", false); return(View(WebPageData)); }
public ActionResult ReceiveCards(ReceiveCards WebPageData, string returnUrl) { String ErrorCode; if (ModelState.IsValid) { // Attempt to add the card String CardToAdd = WebPageData.FirstCardNumber; if (WebPageData.NumberOfCards != null) { Int32 CountToAdd = Convert.ToInt32(WebPageData.NumberOfCards); ErrorCode = CardServiceInstance.AddCards(CardToAdd, CountToAdd, "", "", ""); } else { if (WebPageData.LastCardNumber != null) { String LastCardToAdd = WebPageData.LastCardNumber; ErrorCode = CardServiceInstance.AddCards(CardToAdd, LastCardToAdd, "", "", ""); } else { ErrorCode = CardServiceInstance.AddCard(CardToAdd, "", "", ""); } } if (ErrorCode == "APP ") { WebPageData.LastCardNumber = ""; ModelState.AddModelError("", "Card(s) Received into Inventory"); } else { ModelState.AddModelError("", "Failed to create the record: " + Utility.ConvertErrorCodes(ErrorCode)); } } return(View()); }