public static bool CardProfileExists(CardProfile cardProfile) { try { var existingCardProfile = new CardProfile(); using (var context = new PersoDBEntities()) { existingCardProfile = context.CardProfiles .Where(t => t.Name.Equals(cardProfile.Name)) .FirstOrDefault(); } if (existingCardProfile == null) { return(false); } else { return(true); } } catch (Exception ex) { throw ex; } }
public static bool Update(CardProfile cardProfile) { try { return(CardProfileDL.Update(cardProfile)); } catch (Exception ex) { throw ex; } }
public HttpResponseMessage UpdateCardProfile([FromBody] CardProfile cardProfile) { try { bool result = CardProfilePL.Update(cardProfile); return(result.Equals(true) ? Request.CreateResponse(HttpStatusCode.OK, "Card profile updated successfully") : Request.CreateResponse(HttpStatusCode.BadRequest, "Request failed")); } catch (Exception ex) { ErrorHandler.WriteError(ex); var response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return(response); } }
public static bool Save(CardProfile cardProfile) { try { using (var context = new PersoDBEntities()) { context.CardProfiles.Add(cardProfile); context.SaveChanges(); } return(true); } catch (Exception ex) { throw ex; } }
public static bool Save(CardProfile cardProfile, out string message) { try { if (CardProfileDL.CardProfileExists(cardProfile)) { message = string.Format("Card profile with name: {0} exists already", cardProfile.Name); return(false); } else { message = string.Empty; return(CardProfileDL.Save(cardProfile)); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Method to check whether valid profile time limit exists or not /// </summary> /// <param name="cardProfile">Card profile</param> /// <returns>True or false</returns> public bool ValidProfileTimeLimit(ref CardProfile cardProfile) // checking whether purchase is in a valid time period for the card { var sTime = DateTime.Now; var sdate = DateTime.Now; var dayOfWeek = (byte)DateAndTime.Weekday(sdate); //sTime = DateTime.Parse(Sdate.ToString("hh:mm:ss")); var timeLimit = _cardService.GetCardProfileTimeLimit(cardProfile.ProfileID, dayOfWeek); var offSet = _policyManager.LoadStoreInfo().OffSet; if (timeLimit == null) { return(false); } if (timeLimit.AllowPurchase == false) { cardProfile.Reason = _resourceManager.GetResString(offSet, 466) + " " + DateAndTime.WeekdayName(dayOfWeek, FirstDayOfWeekValue: FirstDayOfWeek.Sunday); //" Purchase is not allowed with this card on " } else { if (!timeLimit.TimeRestriction) { return(true); } if (sTime.TimeOfDay >= timeLimit.StartTime.TimeOfDay && sTime.TimeOfDay <= timeLimit.EndTime.TimeOfDay) { return(true); } // mvarreason = " Purchase is allowed with this card on " & WeekdayName(DayOfWeek, , vbSunday) & " only between " & !starttime & " and " & !EndTime cardProfile.Reason = _resourceManager.GetResString(offSet, 467) + " " + DateAndTime.WeekdayName(dayOfWeek, FirstDayOfWeekValue: FirstDayOfWeek.Sunday) + " " + _resourceManager.GetResString(offSet, 468) + " " + timeLimit.StartTime.ToString("hh:mm tt") + " " + _resourceManager.GetResString(offSet, 469) + " " + timeLimit.EndTime.ToString("hh:mm tt"); } return(false); }
public static bool Update(CardProfile cardProfile) { try { var existingCardProfile = new CardProfile(); using (var context = new PersoDBEntities()) { existingCardProfile = context.CardProfiles .Where(t => t.ID == cardProfile.ID) .FirstOrDefault(); } if (existingCardProfile != null) { existingCardProfile.Name = cardProfile.Name; existingCardProfile.CardType = cardProfile.CardType; existingCardProfile.CardBin = cardProfile.CardBin; existingCardProfile.CEDuration = cardProfile.CEDuration; using (var context = new PersoDBEntities()) { context.Entry(existingCardProfile).State = EntityState.Modified; context.SaveChanges(); } return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Perform a swipe action (Like, Superlike, Pass) on a user. /// </summary> /// <param name="profile">The profile retrieved from calling GetAllCardsAsync()</param> /// <param name="type">Swipe Type (Like, Superlike, Pass)</param> /// <param name="locale">Locale</param> /// <returns></returns> public async Task <object> SwipeAsync(CardProfile profile, SwipeType type, string locale = "en-GB") { var user_id = profile.UserInfo.Id; object ret; switch (type) { case SwipeType.Like: ret = await LikeAsync(user_id, locale).ConfigureAwait(false); break; case SwipeType.Superlike: ret = await SuperLikeAsync(user_id, locale).ConfigureAwait(false); break; default: ret = await PassAsync(user_id, locale).ConfigureAwait(false); break; } return(ret); }
public HttpResponseMessage SaveCardProfile([FromBody] CardProfile cardProfile) { try { string errMsg = string.Empty; bool result = CardProfilePL.Save(cardProfile, out errMsg); if (string.IsNullOrEmpty(errMsg)) { return(result.Equals(true) ? Request.CreateResponse(HttpStatusCode.OK, "Card profile added successfully.") : Request.CreateResponse(HttpStatusCode.BadRequest, "Request failed")); } else { var response = Request.CreateResponse(HttpStatusCode.BadRequest, errMsg); return(response); } } catch (Exception ex) { ErrorHandler.WriteError(ex); var response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return(response); } }
/// <summary> /// Method to find if valid transaction limits exists for profile or not /// </summary> /// <param name="cardProfile">Card profile</param> /// <param name="cardNumber">Card number</param> /// <returns>True or false</returns> public bool ValidTransactionLimits(ref CardProfile cardProfile, string cardNumber) { //1- check single transaction limit . If above than limit adjust the amount only for single transaction and ask the question // 2- check daily transaction number limit ( 0 means unlimited) //3- check daily transaction amount limit( 0 means unlimited)If above than limit adjust the amount only for single transaction and ask the question //4 - check monthly transaction amount limit( 0 means unlimited)If above than limit adjust the amount only for single transaction and ask the question // allow partial purchase, if one of the single, daily or monthly criteria fails not allowing purchase with the card - ask quetion and if continue use the balane, no not use the card . decimal balance; var offSet = _policyManager.LoadStoreInfo().OffSet; var returnValue = true; cardProfile.PartialUse = false; // if (cardProfile.SngleTransaction != 0) { //shiny jun2,2010 if (Math.Abs(cardProfile.PurchaseAmount) > cardProfile.SngleTransaction) { balance = (decimal)cardProfile.SngleTransaction; cardProfile.PartialUse = true; cardProfile.Reason = _resourceManager.GetResString(offSet, 480) + Convert.ToString(cardProfile.SngleTransaction); //& GetResString(481) & Balance & vbCrLf } else { balance = (decimal)cardProfile.PurchaseAmount; cardProfile.Reason = ""; } // If Abs(Me.PurchaseAmount) > Me.SngleTransaction Then 'added the abs value for refund we shouldn't allow more than single transaction limit if (cardProfile.PurchaseAmount < 0) { cardProfile.PurchaseAmount = (double)(-1 * balance); //Me.SngleTransaction } else { cardProfile.PurchaseAmount = (double)balance; //Me.SngleTransaction } // End If // } if (!(cardProfile.PurchaseAmount > 0)) { return(true); } if (cardProfile.TransactionsPerDay != 0) { if (cardProfile.TransactionsPerDay <= DailyTransCnt(cardNumber)) { returnValue = false; // failed ' cardProfile.Reason = _resourceManager.GetResString(offSet, 463) + " " + Convert.ToString(cardProfile.TransactionsPerDay); // Maximum card transactions per day is } } decimal used; if (returnValue) // not yet failed' passed daily cnt limit { if (cardProfile.DailyTransaction != 0 & cardProfile.PurchaseAmount > 0) //checking daily amount limit only for sales { //SHINY JUNE2,210 used = System.Convert.ToDecimal(TransAmountLimit(cardNumber, 1)); balance = (decimal)(cardProfile.DailyTransaction - (double)used); if (balance <= 0) // no balance { // If Me.DailyTransaction < TransAmountLimit(cardnumber, 1) + Me.PurchaseAmount Then returnValue = false; // failed cardProfile.Reason = _resourceManager.GetResString(offSet, 464) + " " + Convert.ToString(cardProfile.DailyTransaction); } else { if (cardProfile.PurchaseAmount > (double)balance) { cardProfile.PurchaseAmount = (double)balance; cardProfile.PartialUse = true; cardProfile.Reason = _resourceManager.GetResString(offSet, 478) + Convert.ToString(cardProfile.DailyTransaction) + _resourceManager.GetResString(offSet, (short)481) + System.Convert.ToString(balance); // Else // Me.PurchaseAmount = Me.PurchaseAmount } // } } } if (returnValue) // not yet failed' passed daily cnt limit and daily trans limit { if (cardProfile.MonthlyTransaction != 0 & cardProfile.PurchaseAmount > 0) //checking monthly amount limit { //SHINY JUNE3,210 used = System.Convert.ToDecimal(TransAmountLimit(cardNumber, 2)); balance = (decimal)(cardProfile.MonthlyTransaction - (double)used); if (balance <= 0) // no balance to purchase { // If Me.MonthlyTransaction < TransAmountLimit(cardnumber, 2) + Me.PurchaseAmount Then returnValue = false; // failed cardProfile.Reason = _resourceManager.GetResString(offSet, 465) + " " + Convert.ToString(cardProfile.MonthlyTransaction); //"Maximum card transaction amount per month is " } else { if (!(cardProfile.PurchaseAmount > (double)balance)) { return(true); } cardProfile.PurchaseAmount = (double)balance; cardProfile.PartialUse = true; cardProfile.Reason = _resourceManager.GetResString(offSet, 479) + Convert.ToString(cardProfile.MonthlyTransaction) + _resourceManager.GetResString(offSet, (short)481) + System.Convert.ToString(balance); // Else // Me.PurchaseAmount = Me.PurchaseAmount // } } } return(returnValue); }
/// <summary> /// Method to check whether valid products are present for profile or not /// </summary> /// <param name="cardProfile">Card profile</param> /// <param name="cSale"></param> /// <returns>True or false</returns> public bool ValidProductsForProfile(ref CardProfile cardProfile, Sale cSale) // checking whether this sales product is valid based on profile product restriction setting { bool returnValue; Sale_Line sl; // ValidProductsForProfile = False cardProfile.PromptForFuel = false; // ' -Make this true only if there is fuel products and using this card for purchase ' // mvarReason = GetResString(484) 'GetResString(1441) '" This card can't be used for buying selected products." cardProfile.RestrictedUse = false; double validAmount = 0; var offSet = _policyManager.LoadStoreInfo().OffSet; var all = _resourceManager.GetResString(offSet, 347); var fuelDept = _utilityService.GetFuelDepartmentId(); if (cardProfile.RestrictProducts) // Do not allow product specified in the restriction (exclude them) { foreach (Sale_Line tempLoopVarSl in cSale.Sale_Lines) { sl = tempLoopVarSl; if (!string.IsNullOrEmpty(sl.CardProfileID) && sl.CardProfileID != cardProfile.ProfileID) { continue; } if (!_cardService.IsCardProductRestriction(cardProfile.ProfileID, all, sl)) // no restriction products , since it is not specified { // - ask fuel prompt question only if there is fuel products in the purchase if (sl.Dept == fuelDept) { if (cardProfile.PromptForFuel == false) { cardProfile.PromptForFuel = true; } } //shiny end validAmount = validAmount + (double)sl.Amount - sl.Line_Discount - sl.Discount_Adjust + (double)sl.AddedTax + (double)sl.TotalCharge; sl.CardProfileID = cardProfile.ProfileID; } else { //these are the restricted product in the sale cardProfile.RestrictedUse = true; // } } } else if (cardProfile.RestrictProducts == false) // Allow\Include only products specified in the restricyion { foreach (Sale_Line tempLoopVarSl in cSale.Sale_Lines) { sl = tempLoopVarSl; if (string.IsNullOrEmpty(sl.CardProfileID) || (sl.CardProfileID == cardProfile.ProfileID)) // Sometimes sl.profileid is set, but not paid(e.g Crash recovery)0 { // rs = _dbService.GetRecords("SELECT * FROM CardProductRestriction " + " Where ProfileID =\'" +cardProfile.ProfileID + "\' " + " and ((dept = \'" + _resourceManager.GetResString(offSet,(short)347) + "\' and subdept =\'" + _resourceManager.GetResString(offSet,(short)347) + "\' and subdetail = \'" + _resourceManager.GetResString(offSet,(short)347) + "\' and stockcode = \'" + SL.Stock_Code + "\') or " + " ( dept = \'" + SL.Dept + "\' and subdept = \'" + SL.Sub_Dept + "\' and subdetail = \'" + SL.Sub_Detail + "\') or " + " ( dept = \'" + SL.Dept + "\' and subdept = \'" + SL.Sub_Dept + "\' and subdetail = \'" + _resourceManager.GetResString(offSet,(short)347) + "\') or " + " ( dept = \'" + SL.Dept + "\' and subdept = \'" + _resourceManager.GetResString(offSet,(short)347) + "\' and subdetail = \'" + _resourceManager.GetResString(offSet,(short)347) + "\'))", DataSource.CSCMaster); if (_cardService.IsCardProductRestriction(cardProfile.ProfileID, all, sl)) // allow products , since it is specified { // - ask fuel prompt question only if there is fuel products in the purchase if (sl.Dept == _utilityService.GetFuelDepartmentId()) { if (cardProfile.PromptForFuel == false) { cardProfile.PromptForFuel = true; } } //shiny end validAmount = validAmount + (double)sl.Amount - sl.Line_Discount - sl.Discount_Adjust + (double)sl.AddedTax + (double)sl.TotalCharge; sl.CardProfileID = cardProfile.ProfileID; } else { cardProfile.RestrictedUse = true; // 'these are the restricted product in the sale } } } } if (validAmount != 0) { returnValue = true; cardProfile.Reason = ""; } else { cardProfile.Reason = _resourceManager.GetResString(offSet, 484); returnValue = false; } cardProfile.PurchaseAmount = cardProfile.PurchaseAmount + validAmount; return(returnValue); }