Exemple #1
0
        public virtual Result Add()
        {
            try
            {
                Result result = null;
                #region Validate EmployeeCodeWithSamePeriod

                result = CheckPromotionCardsPrintingForEmployeeByEmployeeCodeID(this.EmployeesCodes.EmployeeCodeID);
                if (result.EnumMember != PromotionCardsPrintingValidationEnum.Done.ToString())
                {
                    return(result);
                }
                #endregion

                PromotionCardsPrinting PromotionCardsPrinting = new PromotionCardsPrinting()
                {
                    EmployeeCodeID    = this.EmployeesCodes.EmployeeCodeID,
                    PromotionPeriodID = this.PromotionsPeriod.PromotionPeriodID,
                    CreatedDate       = DateTime.Now,
                    CreatedBy         = this.LoginIdentity.EmployeeCodeID
                };
                this.PromotionCardPrintingID = new PromotionCardsPrintingDAL().Insert(PromotionCardsPrinting);
                result = new Result()
                {
                    Entity     = this,
                    EnumType   = typeof(PromotionCardsPrintingValidationEnum),
                    EnumMember = PromotionCardsPrintingValidationEnum.Done.ToString(),
                };
                return(result);
            }
            catch
            {
                throw;
            }
        }
Exemple #2
0
        public virtual Result CheckPromotionCardsPrintingForEmployeeByEmployeeCodeID(int EmployeeCodeID)
        {
            try
            {
                List <PromotionsPeriodsBLL> promotionsPeriods       = new PromotionsPeriodsBLL().GetPromotionsPeriods();
                PromotionsPeriodsBLL        promotionsPeriodsActive = promotionsPeriods.FirstOrDefault(c => (bool)c.IsActive);
                if (promotionsPeriodsActive == null)
                {
                    return(new Result()
                    {
                        Entity = this,
                        EnumType = typeof(PromotionCardsPrintingValidationEnum),
                        EnumMember = PromotionCardsPrintingValidationEnum.RejectedBecauseOfThereIsNoActivePromotionPeriod.ToString(),
                    });
                }

                List <PromotionCardsPrinting> promotionCardsPrintings = new PromotionCardsPrintingDAL().GetPromotionCardsPrintingByEmployeeCodeID(EmployeeCodeID);
                PromotionCardsPrinting        PromotionCardsPrinting  = promotionCardsPrintings.FirstOrDefault(c => c.PromotionPeriodID == promotionsPeriodsActive.PromotionPeriodID);
                if (PromotionCardsPrinting != null)
                {
                    return(new Result()
                    {
                        Entity = new PromotionCardsPrintingBLL().MapPromotionCardsPrinting(PromotionCardsPrinting),
                        EnumType = typeof(PromotionCardsPrintingValidationEnum),
                        EnumMember = PromotionCardsPrintingValidationEnum.RejectedBecauseOfEmployeeHaveRecordWithSamePeriod.ToString(),
                    });
                }


                return(new Result()
                {
                    Entity = new PromotionCardsPrintingBLL()
                    {
                        EmployeesCodes = new EmployeesCodesBLL()
                        {
                            EmployeeCodeID = EmployeeCodeID
                        }, PromotionsPeriod = new PromotionsPeriodsBLL()
                        {
                            PromotionPeriodID = promotionsPeriodsActive.PromotionPeriodID
                        }
                    },
                    EnumType = typeof(PromotionCardsPrintingValidationEnum),
                    EnumMember = PromotionCardsPrintingValidationEnum.Done.ToString(),
                });
            }
            catch
            {
                throw;
            }
        }
Exemple #3
0
 internal PromotionCardsPrintingBLL MapPromotionCardsPrinting(PromotionCardsPrinting PromotionCardsPrinting)
 {
     try
     {
         PromotionCardsPrintingBLL PromotionCardsPrintingBLL = null;
         if (PromotionCardsPrinting != null)
         {
             PromotionCardsPrintingBLL = new PromotionCardsPrintingBLL()
             {
                 PromotionCardPrintingID = PromotionCardsPrinting.PromotionCardPrintingID,
                 PromotionsPeriod        = new PromotionsPeriodsBLL().MapPromotionPeriod(PromotionCardsPrinting.PromotionsPeriods),
                 EmployeesCodes          = new EmployeesCodesBLL().MapEmployeeCode(PromotionCardsPrinting.EmployeesCodes),
                 CreatedBy   = new EmployeesCodesBLL().MapEmployeeCode(PromotionCardsPrinting.CreatedByNav),
                 CreatedDate = PromotionCardsPrinting.CreatedDate
             };
         }
         return(PromotionCardsPrintingBLL);
     }
     catch
     {
         throw;
     }
 }