public void Insert(AirtimeBilling.Core.Entities.CustomFee entity)
        {
            if (entity.Id.HasValue) {
                Update(entity);
                return;
            }

            using (var db = DbFactory.GetDataContext())
            {
                var fee = new CustomFee();
                fee.PopulateFromEntity(entity);

                db.CustomFees.InsertOnSubmit(fee);
                db.SubmitChanges();
                entity.Inserted(fee.CustomFeeId);
            }
        }
Exemple #2
0
        public ResponseBase SaveCustomFee(CustomFee customFee)
        {
            var response = new ResponseBase();

            try {
                if (customFee.Id.HasValue) {
                    _customFeeRepository.Update(customFee);
                } else {
                    _customFeeRepository.Insert(customFee);
                    if (!customFee.Id.HasValue)
                    {
                        response.IsSuccessful = false;
                        response.Message = "Addition of new Custom Fee has failed";
                        return response;
                    }

                }
                response.IsSuccessful = true;
            } catch (Exception ex) {
                LoggingUtility.LogException(ex);
                response.IsSuccessful = false;
                response.Message = "Could not " + (customFee.Id.HasValue ? "add" : "update") + " the custom fee";
            }
            return response;
        }
Exemple #3
0
        public ResponseBase RemoveCustomFee(CustomFee customFee)
        {
            var response = new ResponseBase();

            // Check no contracts are using this fee.
            var contracts = _contractRepository.GetAllContractsWithCustomFee(customFee);
            if (contracts.Count > 0) {
                response.IsSuccessful = false;
                response.Message = "Cannot delete Custom Fees still associated with contracts";
                return response;
            }

            try {
                _customFeeRepository.Delete(customFee);
                response.IsSuccessful = true;
            } catch (Exception ex) {
                LoggingUtility.LogException(ex);
                response.IsSuccessful = false;
                response.Message = "Could not remove the custom fee";
            }
            return response;
        }