コード例 #1
0
        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();
            }
        }
コード例 #2
0
        public IActionResult Put(int id, [FromBody] PBOnDemandViewModel viewModel)
        {
            try
            {
                if (viewModel == null)
                {
                    return(BadRequest());
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                PBOnDemand singleById = _pbOnDemandRepository.GetById(id);

                if (singleById == null)
                {
                    return(NotFound());
                }

                singleById.PBNo            = viewModel.PBNo;
                singleById.MSISDN          = viewModel.MSISDN;
                singleById.PrizeDate       = viewModel.PrizeDate;
                singleById.LastUpdatedBy   = viewModel.LastUpdatedBy;
                singleById.LastUpdatedDate = DateTime.Now;

                _pbOnDemandRepository.Update(singleById);
                int save = _pbOnDemandRepository.Save();

                if (save > 0)
                {
                    return(Ok(Mapper.Map <PBOnDemandViewModel>(singleById)));
                }

                return(BadRequest());
            }
            catch (Exception exception)
            {
                //Do something with the exception
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }