Ejemplo n.º 1
0
 /// <summary>
 /// Resolve remaining parameters
 /// </summary>
 /// <param name="destination"></param>
 /// <param name="source"></param>
 public static void ResolveRemainingParamters(CancellationPolicyClauses destination, CancellationPolicyClauses source, string loggedUser)
 {
     if (source != null)
     {
         destination.CreatedBy   = source.CreatedBy;
         destination.CreatedDate = source.CreatedDate;
     }
     else
     {
         destination.CreatedBy   = loggedUser;
         destination.CreatedDate = DateTime.Now.JakartaOffset();
     }
     destination.UpdatedBy   = loggedUser;
     destination.UpdatedDate = DateTime.Now.JakartaOffset();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Create CancellationPolicyClauses
        /// </summary>
        /// <param name="clauseViewModel"></param>
        /// <returns>returns the cancellation policy clauses id</returns>
        public async Task <BaseResult <CancellationPolicy> > CreateCancellationPolicyClauses(CancellationPolicyClausesViewModel clauseViewModel)
        {
            var result = new BaseResult <CancellationPolicy> {
                Result = new CancellationPolicy()
            };
            CancellationPolicyClauses clause = new CancellationPolicyClauses()
            {
                DaysBeforeArrival     = clauseViewModel.DaysBeforeArrival,
                PercentageCharge      = clauseViewModel.PercentageCharge,
                CancellationChargesId = clauseViewModel.CancellationChargesId,
                CancellationPolicyId  = (int)clauseViewModel.CancellationPolicyId
            };
            ////this.ValidatePolicyClause(cancellationPolicyClauses);
            var insertResult = await this.iCancellationPolicyClausesConnectionLibrary.InsertEntity(clause).ConfigureAwait(false);

            if (insertResult.IsError || insertResult.ExceptionMessage != null)
            {
                result.IsError          = true;
                result.ExceptionMessage = insertResult.ExceptionMessage;
                return(result);
            }
            result.Result.Id = (int)insertResult.Result;
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// AutomapperCancellationPolicyClause
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="model"></param>
        /// <param name="loggedUser"></param>
        /// <returns>CancellationPolicyClauses</returns>
        public static CancellationPolicyClauses AutomapperCancellationPolicyClause(CancellationClauseViewModel viewModel, CancellationPolicyClauses model, string loggedUser)
        {
            var modelMapped = AutoMapper.Mapper.Map <CancellationPolicyClauses>(viewModel);

            modelMapped.CancellationPolicyId = viewModel.CancellationPolicyId;
            modelMapped.IsDeleted            = false;
            ResolveRemainingParamters(modelMapped, model, loggedUser);
            return(modelMapped);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Validates cancellation policy clauses
        /// </summary>
        /// <param name="cancellationPolicyClause"></param>
        /// <returns>returns results based on validation</returns>
        private bool ValidatePolicyClause(CancellationPolicyClauses cancellationPolicyClause)
        {
            int cancellationChrgesId = cancellationPolicyClause.CancellationChargesId;

            var list = iCancellationPolicyClausesConnectionLibrary.GetListByPredicate(p => p.CancellationPolicyId == cancellationPolicyClause.CancellationPolicyId && p.CancellationChargesId == cancellationChrgesId).Result.Result;

            int     daysBeforeArrival = cancellationPolicyClause.DaysBeforeArrival;
            decimal percentage        = cancellationPolicyClause.PercentageCharge;

            List <CancellationPolicyClauses> clist = list.OrderBy(p => p.DaysBeforeArrival).ToList();
            CancellationPolicyClauses        c1 = null, c2 = null;

            foreach (var item in clist)
            {
                if (daysBeforeArrival > item.DaysBeforeArrival)
                {
                    c1 = item;
                    continue;
                }
                else
                {
                    c2 = item;
                    break;
                }
            }
            if (c1 != null && c2 != null)
            {
                if (c1.PercentageCharge > percentage && percentage > c2.PercentageCharge)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (c1 == null)
            {
                if (c2.PercentageCharge < percentage)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (c2 == null)
            {
                if (c1.PercentageCharge > percentage)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Resolve remaining parameters
 /// </summary>
 /// <param name="destination"></param>
 /// <param name="source"></param>
 public static void ResolveRemainingParamters(CancellationPolicyClauses destination, CancellationPolicyClauses source)
 {
     destination.CancellationPolicyId = source.CancellationPolicyId;
 }
Ejemplo n.º 6
0
        public static CancellationPolicyClauses AutomapperCancellationPolicyClause(CancellationPolicyClausesViewModel viewModel, CancellationPolicyClauses model)
        {
            var modelMapped = AutoMapper.Mapper.Map <CancellationPolicyClauses>(viewModel);

            ResolveRemainingParamters(modelMapped, model);
            return(modelMapped);
        }