private void UpdateSubscription(string address, bool activate) { string MSISDN = address.Split(':').LastOrDefault(); List <PBOnDemand> userOnDemandList = _pbOnDemandRepository.GetAll().Where(oItem => oItem.MSISDN == MSISDN).ToList(); userOnDemandList.ForEach(oItem => { oItem.IsActiveSubscription = activate; oItem.LastUpdatedDate = DateTime.Now; }); _pbOnDemandRepository.Save(); }
private void SaveAllPBNumbers(string numbers, string address, string msisdnNumber, string pbNumbers, BDAppsRepository bdapps) { PBOnDemand pbOnDemandToUpdate = PBOnDemandRepository.GetAll().FirstOrDefault(oItem => oItem.MSISDN == msisdnNumber && oItem.Keyword == _configurationHelper.SmsKeyword); if (pbOnDemandToUpdate != null) { string concatePBNumbers = pbOnDemandToUpdate.PBNo + "," + pbNumbers; pbOnDemandToUpdate.PBNo = concatePBNumbers.Split(',').Distinct().Aggregate((a, b) => a.Trim() + "," + b.Trim()).ToString(); pbOnDemandToUpdate.LastUpdatedDate = DateTime.Now; PBOnDemandRepository.Update(pbOnDemandToUpdate); PBOnDemandRepository.Save(); } else { PBOnDemand pbOnDemand = new PBOnDemand(); pbOnDemand.MSISDN = msisdnNumber; pbOnDemand.Keyword = numbers.Substring(0, 3).ToUpper().Trim(); pbOnDemand.PBNo = pbNumbers; pbOnDemand.CreatedBy = pbOnDemand.MSISDN; pbOnDemand.LastUpdatedBy = pbOnDemand.MSISDN; pbOnDemand.PrizeDate = DateTime.Now; pbOnDemand.CreatedDate = DateTime.Now; pbOnDemand.LastUpdatedDate = DateTime.Now; pbOnDemand.IsActive = true; pbOnDemand.IsActiveSubscription = bdapps.IsActiveSubscriber(address); PBOnDemandRepository.Add(pbOnDemand); PBOnDemandRepository.Save(); } }
public IActionResult Get() { try { return(Ok(_pbOnDemandRepository.GetAll().Select(x => Mapper.Map <PBOnDemandViewModel>(x)))); } catch (Exception exception) { //logg exception or do anything with it return(StatusCode((int)HttpStatusCode.InternalServerError)); } }