Example #1
0
        /// <summary>
        /// Updates the promotion.
        /// </summary>
        /// <param name="promoteView">The promote view.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">promoteView</exception>
        public string UpdatePromotion(IPromotionView promoteView)
        {
            if (promoteView == null)
            {
                throw new ArgumentNullException(nameof(promoteView));
            }

            var result = string.Empty;

            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    var newPromotion = dbContext.Employees.Find(promoteView.EmployeeId);

                    newPromotion.LevelId = promoteView.LevelId;
                    newPromotion.GradeId = promoteView.GradeId;

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

            return(result);
        }
Example #2
0
        /// <summary>
        /// Creates the promotion view.
        /// </summary>
        /// <param name="promotion">The promotion.</param>
        /// <param name="payScaleCollection">The pay scale collection.</param>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">promotion</exception>
        public IPromotionView CreatePromotionView(IPromotionView promotion, IEmployee employee, IList <IPayScale> payScaleCollection, string message)
        {
            if (promotion == null)
            {
                throw new ArgumentNullException(nameof(promotion));
            }

            var payScaleDDL = GetDropDownList.PayScaleListItem(payScaleCollection, promotion.PayScaleId);

            promotion.EmployeeId        = employee.EmployeeId;
            promotion.EmployeeName      = employee.LastName + " " + employee.FirstName;
            promotion.PayScaleDropDown  = payScaleDDL;
            promotion.ProcessingMessage = message;

            return(promotion);
        }
Example #3
0
        /// <summary>
        /// Saves the Promotion information.
        /// </summary>
        /// <param name="onboardInfo">The onboard information.</param>
        /// <returns></returns>
        public string SavePromotionInfo(IPromotionView promotion)
        {
            if (promotion == null)
            {
                throw new ArgumentNullException(nameof(promotion));
            }

            var result = string.Empty;

            var newpromotion = new Promotion
            {
                EmployeeId  = promotion.EmployeeId,
                LevelId     = promotion.LevelId,
                GradeId     = promotion.GradeId,
                CompanyId   = promotion.CompanyId,
                IsActive    = true,
                DateCreated = DateTime.Now
            };

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

            return(result);
        }
 public void SetView(IPromotionView view)
 {
     m_view = view;
 }