示例#1
0
        public async Task ExecuteAsync(UpdatePartnerCommand command)
        {
            if (!command.Validate())
            {
                AddNotification(command.GetNotifications());
                return;
            }

            AddNotification(!partnerRepository.Get().Any(x => x.Id == command.Partner.Id), "Partner Id Not Found");

            if (!IsValid)
            {
                return;
            }


            try
            {
                await partnerRepository.UpdateAsync(command.Partner);
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message, ex);
                AddNotification(ex.Message, System.Net.HttpStatusCode.InternalServerError);
            }
        }
示例#2
0
        public void DeletePartner(string mainCode, string subCode)
        {
            var partnerToRemove = _partnerRepository.Get(c => c.PartnerMainC == mainCode && c.PartnerSubC == subCode);

            if (partnerToRemove != null)
            {
                _partnerRepository.Delete(partnerToRemove);
                var settlements = _partnerSettlementRepository.Query(c => c.PartnerMainC == mainCode && c.PartnerSubC == subCode);
                if (settlements != null)
                {
                    foreach (var settlement in settlements)
                    {
                        _partnerSettlementRepository.Delete(settlement);
                    }
                }
                SavePartner();
            }

            //Delete init customer payment
            var initPartnerPayment = _partnerBalanceRepository.Get(p => p.PartnerMainC == mainCode &&
                                                                   p.PartnerSubC == subCode &&
                                                                   p.PartnerBalanceD == new DateTime(1900, 1, 1));

            if (initPartnerPayment != null)
            {
                _partnerBalanceRepository.Delete(initPartnerPayment);
            }
        }
 public async Task <IActionResult> Get(int id)
 {
     return(Ok(partnerRepository.Get()));
 }