Ejemplo n.º 1
0
        /// <summary>
        /// Gets Cancellation Policy types from MasterData
        /// </summary>
        /// <returns>Returns cancellation policy types :- Non </returns>
        public async Task <IActionResult> GetCancellationPolicyType()
        {
            var cancellationPolicyTypeChargesCache = new BaseResult <List <CancellationPolicyTypeViewModel> >()
            {
                Result = RedisCacheHelper.Instance.Get <List <CancellationPolicyTypeViewModel> >(Constants.CacheKeys.CancellationPolicyTypeList)
            };

            if (cancellationPolicyTypeChargesCache.Result == null || cancellationPolicyTypeChargesCache.Result.Count == 0)
            {
                var cancellationPolicyTypeResult = await iPolicies.GetCancellationPolicyType().ConfigureAwait(false);

                if (cancellationPolicyTypeResult.IsError && cancellationPolicyTypeResult.ExceptionMessage != null)
                {
                    return(StatusCode(500, cancellationPolicyTypeResult));
                }
                else if (cancellationPolicyTypeResult.Result == null || cancellationPolicyTypeResult.Result.Count == 0)
                {
                    return(this.NoContent()); // 204
                }
                else
                {
                    var chargesListVm = DbMapperMasterdata.MapCancellationPolicyType(cancellationPolicyTypeResult);
                    RedisCacheHelper.Instance.Set <List <CancellationPolicyTypeViewModel> >(Constants.CacheKeys.CancellationPolicyTypeList, chargesListVm.Result);
                    return(this.Ok(chargesListVm)); // 200
                }
            }
            return(this.Ok(cancellationPolicyTypeChargesCache));
        }