public long AddChartOfAccount(ChartOfAccountObject chartOfAccount)
 {
     try
     {
         if (chartOfAccount == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.AccountType.Trim().ToLower() == chartOfAccount.AccountType.Trim().ToLower() && m.AccountCode.Trim().ToLower() == chartOfAccount.AccountCode.Trim().ToLower() && chartOfAccount.AccountGroupId == m.AccountGroupId);
         if (duplicates > 0)
         {
             return(-3);
         }
         var chartOfAccountEntity = ModelCrossMapper.Map <ChartOfAccountObject, ChartOfAccount>(chartOfAccount);
         if (chartOfAccountEntity == null || string.IsNullOrEmpty(chartOfAccountEntity.AccountType))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(chartOfAccountEntity);
         _uoWork.SaveChanges();
         return(returnStatus.ChartOfAccountId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #2
0
        public long AddUserProfile(UserProfileObject person)
        {
            try
            {
                if (person == null)
                {
                    return(-2);
                }
                var duplicates = _repository.Count(m => m.LastName.Trim().ToLower() == person.LastName.Trim().ToLower() && m.OtherNames.Trim().ToLower() == person.OtherNames.Trim().ToLower());
                if (duplicates > 0)
                {
                    return(-3);
                }

                var personEntity = ModelCrossMapper.Map <UserProfileObject, UserProfile>(person);

                if (personEntity == null)
                {
                    return(-2);
                }
                var returnStatus = _repository.Add(personEntity);
                _uoWork.SaveChanges();
                return(returnStatus.Id);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Пример #3
0
 public long AddCompany(CompanyObject company)
 {
     try
     {
         if (company == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.Name.Trim().ToLower() == company.Name.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var companyEntity = ModelCrossMapper.Map <CompanyObject, Company>(company);
         if (companyEntity == null || string.IsNullOrEmpty(companyEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(companyEntity);
         _uoWork.SaveChanges();
         return(returnStatus.CompanyId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #4
0
 public long AddCoupon(CouponObject coupon)
 {
     try
     {
         if (coupon == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Title.Trim().ToLower() == coupon.Code.Trim().ToLower() && m.ValidFrom == coupon.ValidFrom && m.ValidTo == coupon.ValidTo);
         if (duplicates > 0)
         {
             return(-3);
         }
         var couponEntity = ModelCrossMapper.Map <CouponObject, Coupon>(coupon);
         if (couponEntity == null || string.IsNullOrEmpty(couponEntity.Title))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(couponEntity);
         _uoWork.SaveChanges();
         return(returnStatus.CouponId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
        public long AddactiveSubscription(ActiveSubscriptionObject activeSubscription)
        {
            try
            {
                if (activeSubscription == null)
                {
                    return(-2);
                }

                //const int stat = (int) SubscriptionStatus.Active;
                //var listToExtend = _repository.GetAll(m => m.StoreIdId == activeSubscription.StoreIdId && m.SubscriptionPackageId == activeSubscription.SubscriptionPackageId && m.SubscriptionStatus == stat).ToList();
                //var subscriptionToExtend = new ActiveSubscription();
                //if (listToExtend.Any())
                //{
                //    subscriptionToExtend = listToExtend[0];
                //}

                var activeSubscriptionEntity = ModelCrossMapper.Map <ActiveSubscriptionObject, ActiveSubscription>(activeSubscription);
                if (activeSubscriptionEntity == null || activeSubscriptionEntity.ActiveSubscriptionId < 1)
                {
                    return(-2);
                }
                var returnStatus = _repository.Add(activeSubscriptionEntity);
                _uoWork.SaveChanges();
                return(returnStatus.ActiveSubscriptionId);
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Пример #6
0
 public long AddStoreSetting(StoreSettingObject storeSetting)
 {
     try
     {
         if (storeSetting == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.StoreId == storeSetting.StoreId);
         if (duplicates > 0)
         {
             return(-3);
         }
         var storeSettingEntity = ModelCrossMapper.Map <StoreSettingObject, StoreSetting>(storeSetting);
         if (storeSettingEntity == null || storeSettingEntity.StoreId < 1)
         {
             return(-2);
         }
         var returnStatus = _repository.Add(storeSettingEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
 public long AddStorePaymentGateway(StorePaymentGatewayObject storePaymentGateway)
 {
     try
     {
         if (storePaymentGateway == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.GatewayName.Trim().ToLower() == storePaymentGateway.GatewayName.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var storePaymentGatewayEntity = ModelCrossMapper.Map <StorePaymentGatewayObject, StorePaymentGateway>(storePaymentGateway);
         if (storePaymentGatewayEntity == null || string.IsNullOrEmpty(storePaymentGatewayEntity.GatewayName))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(storePaymentGatewayEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StorePaymentGatewayId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #8
0
 public long AddSupplier(SupplierObject supplier)
 {
     try
     {
         if (supplier == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => (m.CompanyName.Trim().ToLower() == supplier.CompanyName.Trim().ToLower() || m.TIN != null && supplier.TIN != null && m.TIN.Trim() == supplier.TIN.Trim()));
         if (duplicates > 0)
         {
             return(-3);
         }
         var supplierEntity = ModelCrossMapper.Map <SupplierObject, Supplier>(supplier);
         if (supplierEntity == null || string.IsNullOrEmpty(supplierEntity.CompanyName))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(supplierEntity);
         _uoWork.SaveChanges();
         return(returnStatus.SupplierId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #9
0
 public long AddStoreOutlet(StoreOutletObject storeOutlet)
 {
     try
     {
         if (storeOutlet == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.OutletName.Trim().ToLower() == storeOutlet.OutletName.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var storeOutletEntity = ModelCrossMapper.Map <StoreOutletObject, StoreOutlet>(storeOutlet);
         if (storeOutletEntity == null || storeOutletEntity.StoreAddressId < 1)
         {
             return(-2);
         }
         var returnStatus = _repository.Add(storeOutletEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreOutletId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
 public int AddDeliveryMethod(DeliveryMethodObject deliveryMethod)
 {
     try
     {
         if (deliveryMethod == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.MethodTitle.Trim().ToLower().Equals(deliveryMethod.MethodTitle.Trim().ToLower()));
         if (duplicates > 0)
         {
             return(-3);
         }
         var deliveryMethodEntity = ModelCrossMapper.Map <DeliveryMethodObject, DeliveryMethod>(deliveryMethod);
         if (deliveryMethodEntity == null || string.IsNullOrEmpty(deliveryMethodEntity.MethodTitle))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(deliveryMethodEntity);
         _uoWork.SaveChanges();
         return(returnStatus.DeliveryMethodId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #11
0
 public long AddCurrency(CurrencyObject currency)
 {
     try
     {
         if (currency == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower().Equals(currency.Name.Trim().ToLower()) && currency.CountryId.Equals(m.CountryId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var currencyEntity = ModelCrossMapper.Map <CurrencyObject, Currency>(currency);
         if (currencyEntity == null || string.IsNullOrEmpty(currencyEntity.Name))
         {
             return(-2);
         }
         _repository.Add(currencyEntity);
         _uoWork.SaveChanges();
         return(5);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #12
0
 public long AddStockUpload(StockUploadObject stockUpload)
 {
     try
     {
         if (stockUpload == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.StoreItemStockId == stockUpload.StoreItemStockId && stockUpload.ImageViewId == m.ImageViewId);
         if (duplicates > 0)
         {
             return(-3);
         }
         var stockUploadEntity = ModelCrossMapper.Map <StockUploadObject, StockUpload>(stockUpload);
         if (stockUploadEntity == null || stockUploadEntity.StoreItemStockId < 1)
         {
             return(-2);
         }
         var returnStatus = _repository.Add(stockUploadEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StockUploadId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #13
0
 public long AddPaymentMethod(PaymentMethodObject paymentMethod)
  {
      try
      {
          if (paymentMethod == null)
          {
              return -2;
          }
          if (_repository.Count(m => m.Name.Trim().ToLower() == paymentMethod.Name.Trim().ToLower()) > 0)
          {
              return -3;
          }
          var paymentMethodEntity = ModelCrossMapper.Map<PaymentMethodObject, PaymentMethod>(paymentMethod);
          if (paymentMethodEntity == null || string.IsNullOrEmpty(paymentMethodEntity.Name))
          {
              return -2;
          }
          var returnStatus = _repository.Add(paymentMethodEntity);
          _uoWork.SaveChanges();
          return returnStatus.PaymentMethodId;
      }
      catch (Exception ex)
      {
          ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
          return 0;
      }
  }
Пример #14
0
 public long AddSalutation(SalutationObject salutation)
 {
     try
     {
         if (salutation == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower() == salutation.Name.Trim().ToLower() && (m.SalutationId != salutation.SalutationId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var salutationEntity = ModelCrossMapper.Map <SalutationObject, Salutation>(salutation);
         if (salutationEntity == null || string.IsNullOrEmpty(salutationEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(salutationEntity);
         _uoWork.SaveChanges();
         return(returnStatus.SalutationId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #15
0
 public long AddAccountGroup(AccountGroupObject accountGroup)
 {
     try
     {
         if (accountGroup == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower() == accountGroup.Name.Trim().ToLower());
         if (duplicates > 0)
         {
             return(-3);
         }
         var accountGroupEntity = ModelCrossMapper.Map <AccountGroupObject, AccountGroup>(accountGroup);
         if (accountGroupEntity == null || string.IsNullOrEmpty(accountGroupEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(accountGroupEntity);
         _uoWork.SaveChanges();
         return(returnStatus.AccountGroupId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
        public long AddSubscriptionPackage(SubscriptionPackageObject subscriptionPackage)
        {
            try
            {
                if (subscriptionPackage == null)
                {
                    return(-2);
                }
                var duplicates = _repository.Count(m => m.PackageTitle.Trim().ToLower() == subscriptionPackage.PackageTitle.Trim().ToLower() &&
                                                   subscriptionPackage.FileStorageSpace == m.FileStorageSpace && m.NumberOfOutlets == subscriptionPackage.NumberOfOutlets &&
                                                   m.Registers == subscriptionPackage.Registers && m.NumberOfUsers == subscriptionPackage.NumberOfUsers &&
                                                   m.MaximumTransactions == subscriptionPackage.MaximumTransactions);

                if (duplicates > 0)
                {
                    return(-3);
                }
                var subscriptionPackageEntity = ModelCrossMapper.Map <SubscriptionPackageObject, SubscriptionPackage>(subscriptionPackage);
                if (subscriptionPackageEntity == null || string.IsNullOrEmpty(subscriptionPackageEntity.PackageTitle))
                {
                    return(-2);
                }
                var returnStatus = _repository.Add(subscriptionPackageEntity);
                _uoWork.SaveChanges();
                return(returnStatus.SubscriptionPackageId);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Пример #17
0
 public long AddStoreDepartment(StoreDepartmentObject storeDepartment)
 {
     try
     {
         if (storeDepartment == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower() == storeDepartment.Name.Trim().ToLower());
         if (duplicates > 0)
         {
             return(-3);
         }
         var storeDepartmentEntity = ModelCrossMapper.Map <StoreDepartmentObject, StoreDepartment>(storeDepartment);
         if (storeDepartmentEntity == null || string.IsNullOrEmpty(storeDepartmentEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(storeDepartmentEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreDepartmentId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #18
0
 public long AddPaymentType(PaymentTypeObject paymentType)
 {
     try
     {
         if (paymentType == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower() == paymentType.Name.Trim().ToLower() && (m.PaymentTypeId != paymentType.PaymentTypeId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var paymentTypeEntity = ModelCrossMapper.Map <PaymentTypeObject, PaymentType>(paymentType);
         if (paymentTypeEntity == null || string.IsNullOrEmpty(paymentTypeEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(paymentTypeEntity);
         _uoWork.SaveChanges();
         return(returnStatus.PaymentTypeId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #19
0
 public long AddAlaCarte(AlaCarteObject alaCarte)
 {
     try
     {
         if (alaCarte == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => String.Equals(m.ItemName.Trim(), alaCarte.ItemName.Trim(), StringComparison.CurrentCultureIgnoreCase));
         if (duplicates > 0)
         {
             return(-3);
         }
         var alaCarteEntity = ModelCrossMapper.Map <AlaCarteObject, AlaCarte>(alaCarte);
         if (alaCarteEntity == null || string.IsNullOrEmpty(alaCarteEntity.ItemName))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(alaCarteEntity);
         _uoWork.SaveChanges();
         return(returnStatus.AlaCarteId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #20
0
 public long AddRegister(RegisterObject register)
 {
     try
     {
         if (register == null)
         {
             return -2;
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower().Equals(register.Name.Trim().ToLower()) && register.CurrentOutletId.Equals(m.CurrentOutletId));
         if (duplicates > 0)
         {
             return -3;
         }
         var registerEntity = ModelCrossMapper.Map<RegisterObject, Register>(register);
         if (registerEntity == null || string.IsNullOrEmpty(registerEntity.Name))
         {
             return -2;
         }
         var returnStatus = _repository.Add(registerEntity);
         _uoWork.SaveChanges();
         return returnStatus.RegisterId;
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return 0;
     }
 }
Пример #21
0
        public long AddBankAccount(BankAccountObject bankAccount)
        {
            try
            {
                if (bankAccount == null)
                {
                    return(-2);
                }
                if (_repository.Count(m => m.CustomerId == bankAccount.CustomerId && m.BankId == bankAccount.BankId && m.AccountName == bankAccount.AccountName && m.AccountNo == bankAccount.AccountNo) > 0)
                {
                    return(-3);
                }

                var bankAccountEntity = ModelCrossMapper.Map <BankAccountObject, BankAccount>(bankAccount);
                if (bankAccountEntity == null || bankAccountEntity.BankId < 1)
                {
                    return(-2);
                }
                var returnStatus = _repository.Add(bankAccountEntity);
                _uoWork.SaveChanges();
                return(returnStatus.BankAccountId);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
 public long AddUnitsOfMeasurement(UnitsOfMeasurementObject unitsOfMeasurement)
 {
     try
     {
         if (unitsOfMeasurement == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.UoMCode.Trim().ToLower() == unitsOfMeasurement.UoMCode.Trim().ToLower());
         if (duplicates > 0)
         {
             return(-3);
         }
         var unitsOfMeasurementEntity = ModelCrossMapper.Map <UnitsOfMeasurementObject, UnitsOfMeasurement>(unitsOfMeasurement);
         if (unitsOfMeasurementEntity == null || string.IsNullOrEmpty(unitsOfMeasurementEntity.UoMCode))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(unitsOfMeasurementEntity);
         _uoWork.SaveChanges();
         return(returnStatus.UnitOfMeasurementId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #23
0
 public long AddJobRole(JobRoleObject jobRole)
 {
     try
     {
         if (jobRole == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.JobTitle.Trim().ToLower() == jobRole.JobTitle.Trim().ToLower() && (m.JobRoleId != jobRole.JobRoleId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var jobRoleEntity = ModelCrossMapper.Map <JobRoleObject, JobRole>(jobRole);
         if (jobRoleEntity == null || string.IsNullOrEmpty(jobRoleEntity.JobTitle))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(jobRoleEntity);
         _uoWork.SaveChanges();
         return(returnStatus.JobRoleId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #24
0
 public long AddImageView(ImageViewObject imageView)
 {
     try
     {
         if (imageView == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower() == imageView.Name.Trim().ToLower() && (m.ImageViewId != imageView.ImageViewId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var imageViewEntity = ModelCrossMapper.Map <ImageViewObject, ImageView>(imageView);
         if (imageViewEntity == null || string.IsNullOrEmpty(imageViewEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(imageViewEntity);
         _uoWork.SaveChanges();
         return(returnStatus.ImageViewId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #25
0
 public long AddCountry(StoreCountryObject country)
 {
     try
     {
         if (country == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower() == country.Name.Trim().ToLower() && (m.StoreCountryId != country.StoreCountryId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var countryEntity = ModelCrossMapper.Map <StoreCountryObject, StoreCountry>(country);
         if (countryEntity == null || string.IsNullOrEmpty(countryEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(countryEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreCountryId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #26
0
 public long AddStoreItem(StoreItemObject storeItem)
 {
     try
     {
         if (storeItem == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.Name.Trim().ToLower() == storeItem.Name.Trim().ToLower() && m.StoreItemBrandId == storeItem.StoreItemBrandId && m.StoreItemCategoryId == storeItem.StoreItemCategoryId && m.StoreItemTypeId == storeItem.StoreItemTypeId) > 0)
         {
             return(-3);
         }
         var storeItemEntity = ModelCrossMapper.Map <StoreItemObject, StoreItem>(storeItem);
         if (storeItemEntity == null || string.IsNullOrEmpty(storeItemEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(storeItemEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreItemId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #27
0
 public long AddBillingCycle(BillingCycleObject billingCycle)
 {
     try
     {
         if (billingCycle == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower().Equals(billingCycle.Name.Trim().ToLower()) || m.Code.Equals(billingCycle.Code));
         if (duplicates > 0)
         {
             return(-3);
         }
         var billingCycleEntity = ModelCrossMapper.Map <BillingCycleObject, BillingCycle>(billingCycle);
         if (billingCycleEntity == null || string.IsNullOrEmpty(billingCycleEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(billingCycleEntity);
         _uoWork.SaveChanges();
         return(returnStatus.BillingCycleId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #28
0
 public long AddStoreItemType(StoreItemTypeObject productType)
 {
     try
     {
         if (productType == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.Name.Trim().ToLower() == productType.Name.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var productTypeEntity = ModelCrossMapper.Map <StoreItemTypeObject, StoreItemType>(productType);
         if (productTypeEntity == null || string.IsNullOrEmpty(productTypeEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(productTypeEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreItemTypeId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #29
0
 public long AddBank(BankObject bank)
 {
     try
     {
         if (bank == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.FullName.Trim().ToLower() == bank.FullName.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         if (_repository.Count(m => m.SortCode.Trim().ToLower() == bank.SortCode.Trim().ToLower()) > 0)
         {
             return(-4);
         }
         var bankEntity = ModelCrossMapper.Map <BankObject, Bank>(bank);
         if (bankEntity == null || string.IsNullOrEmpty(bankEntity.FullName))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(bankEntity);
         _uoWork.SaveChanges();
         return(returnStatus.BankId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
        public long AddSubscriptionSetting(SubscriptionSettingObject store)
        {
            try
            {
                if (store == null)
                {
                    return(-2);
                }
                var settings = _repository.GetAll().ToList();
                if (settings.Any())
                {
                    var setting = settings[0];
                    setting.StoreId          = store.StoreId;
                    setting.SecreteKey       = store.SecreteKey;
                    setting.DatabaseSpace    = store.DatabaseSpace;
                    setting.FileStorageSpace = store.FileStorageSpace;
                    setting.Url                = store.Url;
                    setting.DateSubscribed     = store.DateSubscribed;
                    setting.ExpiryDate         = store.ExpiryDate;
                    setting.SubscriptionStatus = store.SubscriptionStatus;
                    _repository.Update(setting);
                    _uoWork.SaveChanges();
                    return(setting.StoreId);
                }
                var storeEntity = ModelCrossMapper.Map <SubscriptionSettingObject, SubscriptionSetting>(store);
                if (storeEntity == null || store.StoreId < 1)
                {
                    return(-2);
                }
                var returnStatus = _repository.Add(storeEntity);
                _uoWork.SaveChanges();
                return(returnStatus.StoreId);
            }

            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }