예제 #1
0
 public async Task <ClaimDetails> GetClaimsByID(int claimID)
 {
     try
     {
         ClaimDetails claimDetail = await(from claim in _dBContext.Claims.AsNoTracking()
                                          join clainType in _dBContext.ClaimTypes.AsNoTracking() on claim.ClaimType equals clainType.ClaimTypeID
                                          join member in _dBContext.Member.AsNoTracking() on claim.MemberID equals member.MemberID
                                          where claim.ClaimID == claimID
                                          select new ClaimDetails
         {
             ClaimID     = claim.ClaimID,
             ClaimAmount = claim.ClaimAmount,
             ClaimDate   = claim.ClaimDate,
             ClaimType   = clainType.ClaimType,
             Remarks     = claim.Remarks,
             MemberName  = member.FirstName + " " + member.LastName
         }
                                          ).FirstOrDefaultAsync();
         return(claimDetail);
         //return await _dBContext.Claims.AsNoTracking().Where(c => c.ClaimID == claimID).FirstOrDefaultAsync();
     }
     catch (Exception ex)
     {
         Log.Error("Exception occurred on Get Claim By ID", ex);
         throw ex;
     }
 }
예제 #2
0
        public async Task <BaseResponse> UpdateClaims(ClaimDetails claimDetail)
        {
            try
            {
                ClaimTypes claimType = await _dBContext.ClaimTypes.AsNoTracking().Where(c => c.ClaimType == claimDetail.ClaimType).FirstOrDefaultAsync();

                Member member = await _dBContext.Member.AsNoTracking().Where(m => m.FirstName + " " + m.LastName == claimDetail.MemberName).FirstOrDefaultAsync();

                var claim = await _dBContext.Claims.AsNoTracking().Where(c => c.ClaimID == claimDetail.ClaimID).FirstOrDefaultAsync();

                if (claim == null)
                {
                    Claims claims = new Claims()
                    {
                        ClaimID     = 0,
                        ClaimType   = claimType.ClaimTypeID,
                        ClaimAmount = claimDetail.ClaimAmount,
                        ClaimDate   = claimDetail.ClaimDate,
                        Remarks     = claimDetail.Remarks,
                        MemberID    = member.MemberID
                    };
                    _dBContext.Claims.Add(claims);
                    await _dBContext.SaveChangesAsync();

                    return(new BaseResponse()
                    {
                        StatusCode = StatusCodes.Status201Created,
                        StatusDescription = " Claims Details Added Successfully! ",
                        ID = claims.ClaimID
                    });
                }
                else
                {
                    claim = new Claims()
                    {
                        ClaimID     = claimDetail.ClaimID,
                        ClaimType   = claimType.ClaimTypeID,
                        ClaimAmount = claimDetail.ClaimAmount,
                        ClaimDate   = claimDetail.ClaimDate,
                        Remarks     = claimDetail.Remarks,
                        MemberID    = member.MemberID
                    };
                    _dBContext.Claims.UpdateRange(claim);
                    await _dBContext.SaveChangesAsync();

                    return(new BaseResponse()
                    {
                        StatusCode = StatusCodes.Status202Accepted,
                        StatusDescription = " Claims Details Updated Successfully! ",
                        ID = claimDetail.ClaimID
                    });
                }
            }
            catch (Exception ex)
            {
                Log.Error("Exception occurred on Update Claims", ex);
                return(new BaseResponse {
                    StatusCode = StatusCodes.Status500InternalServerError, StatusDescription = "Internal Server Error"
                });
            }
        }
예제 #3
0
 public async Task <BaseResponse> UpdateClaims(ClaimDetails claimDetail)
 {
     return(await _claimsRepository.UpdateClaims(claimDetail));
 }