Esempio n. 1
0
 public PromotionsPeriodsBLL GetByPromotionPeriodID(int PromotionPeriodID)
 {
     try
     {
         PromotionsPeriodsBLL PromotionPeriodBLL = new PromotionsPeriodsBLL();
         PromotionsPeriods    PromotionPeriod    = new PromotionsPeriodsDAL().GetByPromotionPeriodID(PromotionPeriodID);
         PromotionPeriodBLL.PromotionPeriodID = PromotionPeriod.PromotionPeriodID;
         PromotionPeriodBLL.Period            = new PeriodsBLL()
         {
             PeriodID = PromotionPeriod.PeriodID, PeriodName = PromotionPeriod.Periods.PeriodName
         };
         PromotionPeriodBLL.Year = new MaturityYearsBalancesBLL()
         {
             MaturityYearID = PromotionPeriod.YearID, MaturityYear = PromotionPeriod.MaturityYearsBalances != null ? PromotionPeriod.MaturityYearsBalances.MaturityYear : 0
         };
         PromotionPeriodBLL.PromotionStartDate = PromotionPeriod.PromotionStartDate;
         PromotionPeriodBLL.PromotionEndDate   = PromotionPeriod.PromotionEndDate;
         PromotionPeriodBLL.IsActive           = PromotionPeriod.IsActive;
         return(PromotionPeriodBLL);
     }
     catch
     {
         throw;
     }
 }
Esempio n. 2
0
        internal Result IsNoConflictWithPromotionStartAndPromotionEndDates(DateTime StartDate, DateTime EndDate)
        {
            Result            result          = null;
            PromotionsPeriods PromotionPeriod = new PromotionsPeriodsDAL().GetByPromotionPeriodID(this.PromotionPeriodID);

            if (StartDate != PromotionPeriod.PromotionStartDate || EndDate != PromotionPeriod.PromotionEndDate)
            {
                result            = new Result();
                result.EnumType   = typeof(PromotionsPeriodsValidationEnum);
                result.EnumMember = PromotionsPeriodsValidationEnum.RejectedBecauseOfPromotionRecordExistWithThisPromotiosPeriodDates.ToString();
                return(result);
            }
            return(result);
        }
Esempio n. 3
0
        public List <PromotionsPeriodsBLL> GetPromotionsPeriods()
        {
            List <PromotionsPeriods>    PromotionPeriodList    = new PromotionsPeriodsDAL().GetPromotionsPeriods();
            List <PromotionsPeriodsBLL> PromotionPeriodBLLList = new List <PromotionsPeriodsBLL>();

            if (PromotionPeriodList.Count > 0)
            {
                foreach (var item in PromotionPeriodList)
                {
                    PromotionPeriodBLLList.Add(new PromotionsPeriodsBLL().MapPromotionPeriod(item));
                }
            }

            return(PromotionPeriodBLLList);
        }
Esempio n. 4
0
        public List <PromotionsPeriodsBLL> GetPeriodsByYear(int YearID)
        {
            try
            {
                List <PromotionsPeriodsBLL> PromotionPeriodBLLList = new List <PromotionsPeriodsBLL>();
                List <PromotionsPeriods>    PromotionsPeriodsList  = new PromotionsPeriodsDAL().GetByYearID(YearID);
                foreach (var PromotionPeriod in PromotionsPeriodsList)
                {
                    PromotionPeriodBLLList.Add(MapPromotionPeriod(PromotionPeriod));
                }

                return(PromotionPeriodBLLList);
            }
            catch
            {
                throw;
            }
        }
Esempio n. 5
0
        public virtual Result Update()
        {
            try
            {
                Result result = null;

                #region Validation for dates
                if (this.PromotionStartDate > this.PromotionEndDate)
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(PromotionsPeriodsValidationEnum);
                    result.EnumMember = PromotionsPeriodsValidationEnum.RejectedBecauseOfPromotionStartDateIsGreaterThenPromotionEndDate.ToString();
                    return(result);
                }
                #endregion

                #region Check if there is any  promotion record exist
                List <PromotionsRecordsBLL> PromotionsRecords = new PromotionsRecordsBLL().GetPromotionsRecords().Where(x => x.PromotionPeriod.PromotionPeriodID.Equals(this.PromotionPeriodID)).ToList();
                if (PromotionsRecords.Count > 0)
                {
                    result = IsNoConflictWithPromotionStartAndPromotionEndDates(this.PromotionStartDate, this.PromotionEndDate);
                    if (result != null)
                    {
                        return(result);
                    }
                }
                #endregion

                #region Check if there is any active promotion period
                if (this.IsActive == true)
                {
                    List <PromotionsPeriodsBLL> ActivePromotionsPeriods = GetPromotionsPeriods().Where(x => x.IsActive == true && x.PromotionPeriodID != this.PromotionPeriodID).ToList();
                    if (ActivePromotionsPeriods.Count > 0)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(PromotionsPeriodsValidationEnum);
                        result.EnumMember = PromotionsPeriodsValidationEnum.RejectedBecauseOfAlreadyOnePromotionPeriodIsActive.ToString();
                        return(result);
                    }
                }
                #endregion

                PromotionsPeriods PromotionPeriod = new PromotionsPeriods();
                PromotionPeriod.PromotionPeriodID  = this.PromotionPeriodID;
                PromotionPeriod.PeriodID           = this.Period.PeriodID;
                PromotionPeriod.YearID             = this.Year.MaturityYearID;
                PromotionPeriod.PromotionStartDate = this.PromotionStartDate;
                PromotionPeriod.PromotionEndDate   = this.PromotionEndDate;
                PromotionPeriod.IsActive           = this.IsActive;
                PromotionPeriod.LastUpdatedDate    = DateTime.Now;
                PromotionPeriod.LastUpdatedBy      = this.LoginIdentity.EmployeeCodeID;

                int UpdateResult = new PromotionsPeriodsDAL().Update(PromotionPeriod);
                if (UpdateResult != 0)
                {
                    result            = new Result();
                    result.Entity     = this;
                    result.EnumType   = typeof(PromotionsPeriodsValidationEnum);
                    result.EnumMember = PromotionsPeriodsValidationEnum.Done.ToString();
                }

                return(result);
            }
            catch
            {
                throw;
            }
        }