/// <summary> /// This method updates funding source accepted currencies /// </summary> /// <param name="pkFundingSourceID">pkFundingSourceID</param> /// <param name="acceptedCurr">acceptedCurr</param> /// <returns></returns> public bool UpdateFundingSourceAcceptedCurrency(int pkFundingSourceID, string acceptedCurr) { try { using (var unitOfWork = new EFUnitOfWork()) { //Get array of currencies var allCurr = acceptedCurr.Split(','); int parseResult; var sourceAcceptedCurrRepo = new FundingSourceAcceptedCurrencyRepository(new EFRepository <FundingSourceAcceptedCurrency>(), unitOfWork); ObjectSet <FundingSourceAcceptedCurrency> acceptedCurrObjSet = ((CurrentDeskClientsEntities)sourceAcceptedCurrRepo.Repository.UnitOfWork.Context).FundingSourceAcceptedCurrencies; //Get old records and set IsDelete true var oldRecords = acceptedCurrObjSet.Where(curr => curr.FK_FundingSourceID == pkFundingSourceID).ToList(); foreach (var record in oldRecords) { record.IsDeleted = true; } //Insert to repo for each currency foreach (var curr in allCurr) { if (Int32.TryParse(curr, out parseResult)) { FundingSourceAcceptedCurrency fundAcceptedCurr = new FundingSourceAcceptedCurrency(); fundAcceptedCurr.FK_FundingSourceID = pkFundingSourceID; fundAcceptedCurr.FK_LCurrencyValueID = Convert.ToInt32(curr); fundAcceptedCurr.IsDeleted = false; sourceAcceptedCurrRepo.Add(fundAcceptedCurr); } } //Save sourceAcceptedCurrRepo.Save(); return(true); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } }
// Add your own data access methods here. If you wish to // expose your public method to a WCF service, marked them with // the attribute [NCPublish], and another T4 template will generate your service contract /// <summary> /// This method inserts each row for various currency accepted by funding source /// </summary> /// <param name="pkFundingSourceID"></param> /// <param name="acceptedCurr"></param> /// <returns></returns> public bool AddFundingSourceAcceptedCurrency(int pkFundingSourceID, string acceptedCurr) { try { using (var unitOfWork = new EFUnitOfWork()) { var sourceAcceptedCurrRepo = new FundingSourceAcceptedCurrencyRepository(new EFRepository <FundingSourceAcceptedCurrency>(), unitOfWork); //Get array of currencies var allCurr = acceptedCurr.Split(','); int parseResult; //Insert to repo for each currency foreach (var curr in allCurr) { if (Int32.TryParse(curr, out parseResult)) { FundingSourceAcceptedCurrency fundAcceptedCurr = new FundingSourceAcceptedCurrency(); fundAcceptedCurr.FK_FundingSourceID = pkFundingSourceID; fundAcceptedCurr.FK_LCurrencyValueID = Convert.ToInt32(curr); fundAcceptedCurr.IsDeleted = false; sourceAcceptedCurrRepo.Add(fundAcceptedCurr); } } //Save sourceAcceptedCurrRepo.Save(); return(true); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } }