Exemplo n.º 1
0
        /// <summary>
        /// Saves the advertisement model information.
        /// </summary>
        /// <param name="advertisementModelInfo">The advertisement model information.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">advertisementModelInfo</exception>
        public string SaveAdvertisementModelInfo(IAdvertisementModelView advertisementModelInfo)
        {
            if (advertisementModelInfo == null)
            {
                throw new ArgumentNullException(nameof(advertisementModelInfo));
            }

            var result = string.Empty;

            var newRecord = new Advertisement
            {
                Media          = advertisementModelInfo.Media,
                Comment        = advertisementModelInfo.Comment,
                IsStatus       = advertisementModelInfo.IsStatus,
                DigitalFieldId = advertisementModelInfo.DigitalFieldId
            };

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

            return(result);
        }
        /// <summary>
        /// Creates the updated department view.
        /// </summary>
        /// <param name="advertisementModelInfo">The advertisement model information.</param>
        /// <param name="processingMessage">The processing message.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">advertisementModelInfo</exception>
        public IAdvertisementModelView CreateUpdatedAdvertisementModelView(IAdvertisementModelView advertisementModelInfo, string processingMessage)
        {
            if (advertisementModelInfo == null)
            {
                throw new ArgumentNullException(nameof(advertisementModelInfo));
            }

            advertisementModelInfo.ProcessingMessage = processingMessage;

            return(advertisementModelInfo);
        }