/// Saves the income type information.
        /// </summary>
        /// <param name="incomeTypeView">The income type view.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">AdminSaveIncomeType</exception>
        public string SaveIncomeTypeJurisdictionInfo(IIncomeTypeListView incomeTypeListView)
        {
            var result = string.Empty;

            if (incomeTypeListView == null)
            {
                throw new ArgumentException("incomeTypeListView");
            }

            var newRecord = new JurisdictionIncomeType
            {
                IncomeTypeId   = incomeTypeListView.IncomeTypeId,
                JurisdictionId = incomeTypeListView.JurisdictionId,
                IsActive       = true,
            };

            try
            {
                using (
                    var dbContext = (PitalyticsEntities)this.dbContextFactory.GetDbContext())
                {
                    dbContext.JurisdictionIncomeTypes.Add(newRecord);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("SaveIncomeTypeJursidction - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }

            return(result);
        }
        /// <summary>
        /// Edits the type of the income.
        /// </summary>
        /// <param name="incomeTypeView">The income type view.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">
        /// incomeTypeView
        /// or
        /// incometypeDetails
        /// </exception>
        public string EditIncomeType(IIncomeTypeListView incomeTypeView)
        {
            var result = string.Empty;

            if (incomeTypeView == null)
            {
                throw new ArgumentNullException(nameof(incomeTypeView));
            }
            try
            {
                using (
                    var dbContext = (PitalyticsEntities)this.dbContextFactory.GetDbContext())
                {
                    var incometypeDetails = dbContext.IncomeTypes.SingleOrDefault(x => x.IncomeTypeId == incomeTypeView.IncomeTypeId);
                    if (incometypeDetails == null)
                    {
                        throw new ArgumentNullException(nameof(incometypeDetails));
                    }

                    incometypeDetails.IncomeTypeName = incomeTypeView.IncomeTypeName;
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("SaveIncomeType - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }

            return(result);
        }
        /// <summary>
        /// Creates the income type view.
        /// </summary>
        /// <param name="incomeTypeView">The income type view.</param>
        /// <param name="processingMessage">The processing message.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException">incomeTypeView</exception>
        public IIncomeTypeListView CreateIncomeTypeView(IIncomeTypeListView incomeTypeView, string processingMessage)
        {
            if (incomeTypeView == null)
            {
                throw new ArgumentException("incomeTypeView");
            }


            incomeTypeView.ProcessingMessage = processingMessage;
            return(incomeTypeView);
        }
示例#4
0
        /// <summary>
        /// Creates the updated income type jurisdiction view.
        /// </summary>
        /// <param name="incomeTypeListView">The income type ListView.</param>
        /// <param name="infoMessage">The information message.</param>
        /// <returns></returns>
        public IIncomeTypeListView CreateUpdatedIncomeTypeJurisdictionView(IIncomeTypeListView incomeTypeListView, string infoMessage)
        {
            var incomeTypes = this.generalRepository.GetIncomeType();

            incomeTypes = incomeTypes.Where(x => x.IsActive == true).ToList();
            var jurisdiction = this.generalRepository.GetJurisdiction();

            jurisdiction = jurisdiction.Where(x => x.IsActive == true).ToList();

            return(this.generalFactory.CreateUpdatedIncomeTypeJurisdictionView(jurisdiction, incomeTypes, infoMessage, incomeTypeListView));
        }
示例#5
0
        /// <summary>
        /// Processes the income type jurisdiction information.
        /// </summary>
        /// <param name="incomeTypeListView">The income type ListView.</param>
        /// <returns></returns>
        public string ProcessIncomeTypeJurisdictionInfo(IIncomeTypeListView incomeTypeListView)
        {
            var processingMessages = string.Empty;

            var dataValue = this.generalRepository.GetIncomeTypeJurisdiction(incomeTypeListView.JurisdictionId, incomeTypeListView.IncomeTypeId);

            var isRecordExist = (dataValue == null) ? false : true;

            if (isRecordExist)
            {
                processingMessages = Messages.IncomeTypeJurisdictionExist;
                return(processingMessages);
            }

            var incomeTypeInfo = this.generalRepository.SaveIncomeTypeJurisdictionInfo(incomeTypeListView);

            return(incomeTypeInfo);
        }
示例#6
0
        /// <summary>
        /// Updates the income type information.
        /// </summary>
        /// <param name="incomeTypeView">The income type view.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">incomeTypeView</exception>
        public string UpdateIncomeTypeInfo(IIncomeTypeListView incomeTypeView)
        {
            if (incomeTypeView == null)
            {
                throw new ArgumentNullException(nameof(incomeTypeView));
            }

            var processingMessage = string.Empty;

            var dataValue     = this.generalRepository.GetIncomeTypeDescriptionByValue(incomeTypeView.IncomeTypeName);
            var isRecordExist = (dataValue == null) ? false : true;

            if (isRecordExist)
            {
                processingMessage = Messages.IncomeTypeExist;
                return(processingMessage);
            }

            var editIncomeType = this.generalRepository.EditIncomeType(incomeTypeView);

            return(editIncomeType);
        }
        /// <summary>
        /// Creates the updated income type jurisdiction view.
        /// </summary>
        /// <param name="jurisdictions">The jurisdictions.</param>
        /// <param name="incomeTypes">The income types.</param>
        /// <param name="processingMessage">The processing message.</param>
        /// <param name="incomeTypeListView">The income type ListView.</param>
        /// <returns></returns>
        public IIncomeTypeListView CreateUpdatedIncomeTypeJurisdictionView(IList <IJurisdiction> jurisdictions, IList <IIncomeType> incomeTypes, string processingMessage, IIncomeTypeListView incomeTypeListView)

        {
            var incomeTypeDDL   = GetDropdownIncomeTypeList.GetIncomeType(incomeTypes, -1);
            var jurisdictionDDL = GetJurisdictionDropdown.GetJurisdicions(jurisdictions, -1);

            incomeTypeListView.JurisdictionList  = jurisdictionDDL;
            incomeTypeListView.IncomeTypeList    = incomeTypeDDL;
            incomeTypeListView.ProcessingMessage = processingMessage;
            return(incomeTypeListView);
        }
示例#8
0
 /// <summary>
 /// Gets the income type view.
 /// </summary>
 /// <param name="incomeTypeView">The income type view.</param>
 /// <param name="message">The message.</param>
 /// <returns></returns>
 public IIncomeTypeListView GetIncomeTypeView(IIncomeTypeListView incomeTypeView, string message)
 {
     return(this.generalFactory.CreateIncomeTypeView(incomeTypeView, message));
 }