/// <summary>
        /// Saves the industry information.
        /// </summary>
        /// <param name="industryView">The industry view.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">AdminSaveIndustry</exception>
        public string SaveIndustryInfo(IIndustryListView industryView)
        {
            var result = string.Empty;

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

            var newRecord = new Industry
            {
                IndustryName = industryView.IndustryName,
                IsActive     = true
            };

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

            return(result);
        }
        /// <summary>
        /// Edits the industry.
        /// </summary>
        /// <param name="industryView">The industry view.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// industryView
        /// or
        /// industryDetails
        /// </exception>
        public string EditIndustry(IIndustryListView industryView)
        {
            var result = string.Empty;

            if (industryView == null)
            {
                throw new ArgumentNullException(nameof(industryView));
            }
            try
            {
                using (
                    var dbContext = (PitalyticsEntities)this.dbContextFactory.GetDbContext())
                {
                    var industryDetails = dbContext.Industries.SingleOrDefault(x => x.IndustryId == industryView.IndustryId);
                    if (industryDetails == null)
                    {
                        throw new ArgumentNullException(nameof(industryDetails));
                    }

                    industryDetails.IndustryName = industryView.IndustryName;
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("SaveIndustry - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the industry view.
        /// </summary>
        /// <param name="industryView">The industry view.</param>
        /// <param name="processingMessage">The processing message.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">industryView</exception>
        public IIndustryListView CreateIndustryView(IIndustryListView industryView, string processingMessage)
        {
            if (industryView == null)
            {
                throw new ArgumentException("industryView");
            }


            industryView.ProcessingMessage = processingMessage;
            return(industryView);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Processes the industry information.
        /// </summary>
        /// <param name="industryView">The industry view.</param>
        /// <returns></returns>
        public string ProcessIndustryInfo(IIndustryListView industryView)
        {
            var processingMessages = string.Empty;

            var dataValue = this.generalRepository.GetIndustryDescriptionByValue(industryView.IndustryName);

            if (dataValue != null)
            {
                processingMessages = Messages.IndustryExist;
                return(processingMessages);
            }

            processingMessages = this.generalRepository.SaveIndustryInfo(industryView);

            return(processingMessages);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Updates the industry information.
        /// </summary>
        /// <param name="industryView">The industry view.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">industryView</exception>
        public string UpdateIndustryInfo(IIndustryListView industryView)
        {
            if (industryView == null)
            {
                throw new ArgumentNullException(nameof(industryView));
            }

            var processingMessages = string.Empty;

            var dataValue = this.generalRepository.GetIndustryDescriptionByValue(industryView.IndustryName);

            if (dataValue != null)
            {
                processingMessages = Messages.IndustryExist;
                return(processingMessages);
            }
            var editIndustry = this.generalRepository.EditIndustry(industryView);

            return(editIndustry);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Gets the industry view.
 /// </summary>
 /// <param name="industryView">The industry view.</param>
 /// <param name="message">The message.</param>
 /// <returns></returns>
 public IIndustryListView GetIndustryView(IIndustryListView industryView, string message)
 {
     return(this.generalFactory.CreateIndustryView(industryView, message));
 }