Exemplo n.º 1
0
        public void MapToStructEnum()
        {
            var source = TestEnum.Value1.ToString();
            var value  = TypeConversionExtensions.MapToStruct <TestEnum, string>(source);

            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(source, value.ToString());
        }
Exemplo n.º 2
0
        public void MapToTypeGuid()
        {
            var source = Guid.NewGuid().ToString();
            var value  = TypeConversionExtensions.MapToType <Guid, string>(source);

            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(source, value.ToString());
        }
Exemplo n.º 3
0
        public void MapToStructEnum_Nullable()
        {
            var source = (string)null;
            var value  = TypeConversionExtensions.MapToStructOrNull <TestEnum, string>(source);

            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNull(value);
        }
Exemplo n.º 4
0
        public void MapToTypeGuid_Nullable()
        {
            var source = (string)null;
            var value  = TypeConversionExtensions.MapToType <Guid?, string>(source);

            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNull(value);
        }
        public void Convert_Null_To_Value_Type_Default()
        {
            Guid empty = TypeConversionExtensions.Convert <object, Guid>(
                Utilities.TypeConversion.Default,
                null);

            Assert.Equal(Guid.Empty, empty);
        }
Exemplo n.º 6
0
        public List <PLRPartyItem> PartyitemTaxesMapping(int PlrPartyAmountId, int ContactId, List <PLRPartyItem> partitemlist)
        {
            PLRTaxes cl = GetTaxes(ContactId);
            Taxes    t  = new Taxes();

            foreach (PLRPartyItem item in partitemlist)
            {
                if (item.PLRPartyAmountId == PlrPartyAmountId)
                {
                    foreach (PLRPartyItemsTaxes i in item.PLRPartyItemsTaxesList)
                    {
                        if (item.ItemType == "L")
                        {
                            if (i.Tax_Id == cl.GstLaborTaxId)
                            {
                                i.Amount           = t.GstAmount(item.GrossAmount, Convert.ToDecimal(cl.GstLaborRate));
                                i.Tax_Id           = cl.GstLaborTaxId;
                                i.TaxPercentage_Id = cl.GstLaborTaxPercentageId;
                            }
                            else if (i.Tax_Id == cl.GstWHLaborTaxId)
                            {
                                i.Amount           = t.GstWHAmount(item.GrossAmount, Convert.ToDecimal(cl.GstLaborRate), Convert.ToDecimal(cl.GstWHLaborRate));
                                i.Tax_Id           = cl.GstWHLaborTaxId;
                                i.TaxPercentage_Id = cl.GstWHLaborTaxPercentageId;
                            }
                            else if (i.Tax_Id == cl.WHTaxLaborTaxId)
                            {
                                i.Amount           = t.WHTaxAmount(TypeConversionExtensions.GetNullableValue(item.Amount), Convert.ToDecimal(cl.WHLaborRate));
                                i.Tax_Id           = cl.WHTaxLaborTaxId;
                                i.TaxPercentage_Id = cl.WHTaxLaborPercentageId;
                            }
                        }
                        else
                        {
                            if (i.Tax_Id == cl.WHTaxPartTaxId)
                            {
                                i.Amount           = t.WHTaxAmount(TypeConversionExtensions.GetNullableValue(item.Amount), Convert.ToDecimal(cl.WHPartRate));
                                i.Tax_Id           = cl.WHTaxPartTaxId;
                                i.TaxPercentage_Id = cl.WHPartTaxPercentageId;
                            }
                        }
                    }
                }
            }

            return(partitemlist);
        }
Exemplo n.º 7
0
        internal object ConvertTo(object value, Type toType)
        {
            Func <object> getConverter = () =>
            {
                var converterTypeName = TypeConversionExtensions.GetConverterName(toType);

                if (null == converterTypeName)
                {
                    return(null);
                }

                Type convertertype = Type.GetType(converterTypeName);
                return(Activator.CreateInstance(convertertype));
            };

            return(ConvertTo(value, toType, getConverter));
        }
Exemplo n.º 8
0
 public void MapToStructEnumFail(string source)
 {
     TypeConversionExtensions.MapToStruct <TestEnum, string>(source);
 }
Exemplo n.º 9
0
 public void MapToTypeGuidFail(string source)
 {
     TypeConversionExtensions.MapToType <Guid, string>(source);
 }
Exemplo n.º 10
0
 public void MapToStructEnumFail_Nullable(string source)
 {
     TypeConversionExtensions.MapToStructOrNull <TestEnum, string>(source);
 }
Exemplo n.º 11
0
 public void MapToTypeGuidFail_Nullable(string source)
 {
     TypeConversionExtensions.MapToType <Guid?, string>(source);
 }
Exemplo n.º 12
0
        public List <PLRSearchClaim1VM> GetSearchGrid(SearchGridVm searchGridVm)
        {
            List <PLRSearchClaim1VM> result = null;

            searchGridVm.claimNo        = StringExtensions.ConvertToNullableString(searchGridVm.claimNo);
            searchGridVm.policyNo       = StringExtensions.ConvertToNullableString(searchGridVm.policyNo);
            searchGridVm.insuredName    = StringExtensions.ConvertToNullableString(searchGridVm.insuredName);
            searchGridVm.engineNo       = StringExtensions.ConvertToNullableString(searchGridVm.engineNo);
            searchGridVm.registrationNo = StringExtensions.ConvertToNullableString(searchGridVm.registrationNo);
            searchGridVm.chasisNo       = StringExtensions.ConvertToNullableString(searchGridVm.chasisNo);
            searchGridVm.reasons        = StringExtensions.ConvertToNullableString(searchGridVm.reasons);
            DateTime?dateEffective    = DateTimeExtensions.ConvertToNullableDateTime(searchGridVm.effectiveDate);
            DateTime?dateExpiry       = DateTimeExtensions.ConvertToNullableDateTime(searchGridVm.expiryDate);
            DateTime?intimateDateFrom = DateTimeExtensions.ConvertToNullableDateTime(searchGridVm.fromIntimationDate);
            DateTime?intimateDateTo   = DateTimeExtensions.ConvertToNullableDateTime(searchGridVm.toIntimationDate);
            int?     claimTypeId      = TypeConversionExtensions.ConvertToNullableInt(searchGridVm.claimType);



            if (searchGridVm.AssessmentType == UserViewType.Billing || searchGridVm.AssessmentType == UserViewType.ClaimHandler ||
                searchGridVm.AssessmentType == UserViewType.PLR || searchGridVm.AssessmentType == UserViewType.RPLR ||
                searchGridVm.AssessmentType == UserViewType.SDPLR || searchGridVm.AssessmentType == UserViewType.NLCPLR ||
                searchGridVm.AssessmentType == UserViewType.LSSPLR || searchGridVm.AssessmentType == UserViewType.ARPLR ||
                searchGridVm.AssessmentType == UserViewType.TLPLR || searchGridVm.AssessmentType == UserViewType.TSPLR ||
                searchGridVm.AssessmentType == UserViewType.TPLR || searchGridVm.AssessmentType == UserViewType.SPLR)
            {
                result = _context.PLR_SearchClaim1_SP(Convert.ToInt16(searchGridVm.userId),
                                                      searchGridVm.policyNo,
                                                      searchGridVm.insuredName,
                                                      searchGridVm.claimNo,
                                                      searchGridVm.registrationNo,
                                                      searchGridVm.engineNo,
                                                      searchGridVm.chasisNo,
                                                      dateEffective,
                                                      dateExpiry,
                                                      searchGridVm.reasons,
                                                      claimTypeId,
                                                      intimateDateFrom.GetDateTimeTostring(),
                                                      intimateDateTo.GetDateTimeTostring(),
                                                      searchGridVm.AssessmentType,
                                                      Convert.ToInt32(searchGridVm.dispositionId))
                         .Select(x => new PLRSearchClaim1VM
                {
                    Id = x.Id,
                    SalesFormMapping_Id = x.SalesFormMapping_Id,
                    ClaimNo             = x.ClaimNo,
                    IntimationDate      = x.IntimationDate,
                    Stage              = x.Stage,
                    RegistrationNo     = x.RegistrationNo,
                    EngineNo           = x.m_Engine_No,
                    ChassisNo          = x.m_Chasis_No,
                    InsuredName        = x.InsuredName,
                    SalesFormNo        = x.SalesFormNo,
                    EffectiveDate      = x.EffectiveDate,
                    ExpiryDate         = x.ExpiryDate,
                    SalesFormDetail_Id = x.SalesFormDetail_Id,
                    Contact_Id         = x.Contact_Id,
                    Stage_Id           = x.Stage_Id,
                    Company_Id         = x.Company_Id,
                    CloseReason_Id     = x.CloseReason_Id,
                    ReOpenReason_Id    = x.ReOpenReason_Id,
                    PLRStatus          = x.PLRStatus,
                    PLRDispositionId   = x.PLRDispositionId,
                    Active             = x.Active,
                    PLRDisposition     = x.PLRDisposition,
                    ClaimType_Id       = x.ClaimType_Id,
                    ClaimType          = x.ClaimType,
                    Aging              = x.Aging,
                    Reason             = x.Reason,
                    ReserveAmount      = x.ReserveAmount,
                    OutStandingAmount  = x.OutStandingAmount,
                    BusinessType_Id    = x.BusinessType_Id,
                    AddBY              = x.AddBY,
                    AppointmentDate    = x.AppointmentDate,
                    SDitemCount        = x.SDitemCount,
                    ItemCount          = x.itemCount
                }).ToList();


                //removing containing SD part items and submitted claims For Billing
                if (searchGridVm.AssessmentType == UserViewType.SDPLR)
                {
                    result = result.Where(x => x.SDitemCount > 0).ToList();
                }
            }
            else if (searchGridVm.AssessmentType == UserViewType.SuperUser)
            {
                searchGridVm.AssessmentType = searchGridVm.AssessmentType;
                result = _context.PLR_SearchClaim1_SP(Convert.ToInt16(searchGridVm.userId),
                                                      searchGridVm.policyNo,
                                                      searchGridVm.insuredName,
                                                      searchGridVm.claimNo,
                                                      searchGridVm.registrationNo,
                                                      searchGridVm.engineNo,
                                                      searchGridVm.chasisNo,
                                                      dateEffective,
                                                      dateExpiry,
                                                      searchGridVm.reasons,
                                                      claimTypeId,
                                                      intimateDateFrom.GetDateTimeTostring(),
                                                      intimateDateTo.GetDateTimeTostring(),
                                                      searchGridVm.AssessmentType,
                                                      Convert.ToInt32(searchGridVm.dispositionId))
                         .Select(x => new PLRSearchClaim1VM
                {
                    Id = x.Id,
                    SalesFormMapping_Id = x.SalesFormMapping_Id,
                    ClaimNo             = x.ClaimNo,
                    IntimationDate      = x.IntimationDate,
                    Stage              = x.Stage,
                    RegistrationNo     = x.RegistrationNo,
                    EngineNo           = x.m_Engine_No,
                    ChassisNo          = x.m_Chasis_No,
                    InsuredName        = x.InsuredName,
                    SalesFormNo        = x.SalesFormNo,
                    EffectiveDate      = x.EffectiveDate,
                    ExpiryDate         = x.ExpiryDate,
                    SalesFormDetail_Id = x.SalesFormDetail_Id,
                    Contact_Id         = x.Contact_Id,
                    Stage_Id           = x.Stage_Id,
                    Company_Id         = x.Company_Id,
                    CloseReason_Id     = x.CloseReason_Id,
                    ReOpenReason_Id    = x.ReOpenReason_Id,
                    ClaimType_Id       = x.ClaimType_Id,
                    ClaimType          = x.ClaimType,
                    Aging              = x.Aging,
                    Reason             = x.Reason,
                    ReserveAmount      = x.ReserveAmount,
                    OutStandingAmount  = x.OutStandingAmount,
                    BusinessType_Id    = x.BusinessType_Id,
                    AddBY              = x.AddBY
                }).ToList();
            }
            else if (searchGridVm.AssessmentType == UserViewType.FRPLR)
            {
                result = _context.CLA_DGI_FinalReportPLR_SP(Convert.ToInt16(searchGridVm.userId),
                                                            searchGridVm.policyNo,
                                                            searchGridVm.insuredName,
                                                            searchGridVm.claimNo,
                                                            searchGridVm.registrationNo,
                                                            searchGridVm.engineNo,
                                                            searchGridVm.chasisNo,
                                                            dateEffective,
                                                            dateExpiry,
                                                            searchGridVm.reasons,
                                                            claimTypeId,
                                                            intimateDateFrom.GetDateTimeTostring(),
                                                            intimateDateTo.GetDateTimeTostring(),
                                                            searchGridVm.AssessmentType,
                                                            Convert.ToInt32(searchGridVm.dispositionId)
                                                            )
                         .Select(x => new PLRSearchClaim1VM
                {
                    Id = x.Id,
                    SalesFormMapping_Id = x.SalesFormMapping_Id,
                    ClaimNo             = x.ClaimNo,
                    IntimationDate      = x.IntimationDate,
                    Stage              = x.Stage,
                    RegistrationNo     = x.RegistrationNo,
                    EngineNo           = x.m_Engine_No,
                    ChassisNo          = x.m_Chasis_No,
                    InsuredName        = x.InsuredName,
                    SalesFormNo        = x.SalesFormNo,
                    EffectiveDate      = x.EffectiveDate,
                    ExpiryDate         = x.ExpiryDate,
                    SalesFormDetail_Id = x.SalesFormDetail_Id,
                    Contact_Id         = x.Contact_Id,
                    Stage_Id           = x.Stage_Id,
                    Company_Id         = x.Company_Id,
                    CloseReason_Id     = x.CloseReason_Id,
                    ReOpenReason_Id    = x.ReOpenReason_Id,
                    ClaimType_Id       = x.ClaimType_Id,
                    ClaimType          = x.ClaimType,
                    Aging              = x.Aging,
                    Reason             = x.Reason,
                    ReserveAmount      = x.ReserveAmount,
                    OutStandingAmount  = x.OutStandingAmount,
                    BusinessType_Id    = x.BusinessType_Id,
                    AddBY              = x.AddBY
                }).DistinctBy(x => x.Id).ToList();
            }

            GetOrderedGridResult(searchGridVm, result);
            return(result);
        }
Exemplo n.º 13
0
        public static IQueryable <TEntity> FilterByProperty <TEntity>(this IQueryable <TEntity> source, string propertyPath, string operatorType, string value, bool filterEmptyString = false) where TEntity : class
        {
            if (!Enum.TryParse(operatorType, true, out FilterOperator filterOp))
            {
                return(source);
            }

            var type      = typeof(TEntity);
            var parameter = Expression.Parameter(type);

            var propertyAccessExpr = BuildPropertyPathAccessExpression(type, parameter, propertyPath);
            var propertyType       = propertyAccessExpr.Type;

            if (filterOp == FilterOperator.In || filterOp == FilterOperator.NotIn)
            {
                var strValues = !filterEmptyString
                    ? value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _ == NullString ? null : _.Trim()).ToArray()
                    : value.Split(new[] { ',' }).Select(x => x == "empty" ? null : x.Trim()).ToArray();

                ConstantExpression itemsExpr;
                if (propertyType == typeof(string))
                {
                    itemsExpr = Expression.Constant(strValues);
                }
                else
                {
                    var values = strValues.Select(x => TypeConversionExtensions.GetValue(x, propertyType)).ToArray();
                    var array  = Array.CreateInstance(propertyType, strValues.Length);

                    Array.Copy(values, array, array.Length);
                    itemsExpr = Expression.Constant(array);
                }

                Expression predicateExpr = Expression.Call(typeof(Enumerable), "Contains", new[] { propertyType }, itemsExpr, propertyAccessExpr);

                if (filterOp == FilterOperator.NotIn)
                {
                    predicateExpr = Expression.Not(predicateExpr);
                }

                var whereExpr = Expression.Call(typeof(Queryable), "Where", new[] { type }, source.Expression, Expression.Lambda(predicateExpr, parameter));

                return(source.Provider.CreateQuery <TEntity>(whereExpr));
            }

            Expression predicateExpr2;

            switch (filterOp)
            {
            case FilterOperator.Eq:
                predicateExpr2 = Expression.Equal(propertyAccessExpr, Expression.Constant(value, propertyAccessExpr.Type));
                break;

            case FilterOperator.StartsWith:
            case FilterOperator.Contains:

                var operatorMethod = filterOp.ToString();
                var c  = Expression.Constant(value, typeof(string));
                var mi = typeof(string).GetMethod(operatorMethod, new[] { typeof(string) });
                predicateExpr2 = Expression.Call(propertyAccessExpr, mi, c);
                break;

            default:
                throw new NotSupportedException($"This filter {operatorType} is currently not supported.");
            }

            var whereExpr2 = Expression.Call(typeof(Queryable), "Where", new[] { type }, source.Expression, Expression.Lambda <Func <TEntity, bool> >(predicateExpr2, parameter));

            return(source.Provider.CreateQuery <TEntity>(whereExpr2));
        }