public async Task <BaseResponse> SavePhysican(Physican physican)
        {
            try
            {
                var resphysican = await _dBContext.Physican.AsNoTracking().Where(p => p.PhysicianId == physican.PhysicianId).FirstOrDefaultAsync();

                if (resphysican == null)
                {
                    _dBContext.Physican.Add(physican);
                    await _dBContext.SaveChangesAsync();
                }
                else
                {
                    _dBContext.Physican.UpdateRange(physican);
                    await _dBContext.SaveChangesAsync();
                }
                return(new BaseResponse()
                {
                    StatusCode = StatusCodes.Status202Accepted,
                    StatusDescription = " Physican Details Added Successfully! ",
                    ID = physican.PhysicianId
                });
            }
            catch (Exception ex)
            {
                Log.Error("Exception occurred on Save Physican By ID", ex);
                return(new BaseResponse {
                    StatusCode = StatusCodes.Status500InternalServerError, StatusDescription = "Internal Server Error"
                });
            }
        }
        public async Task <BaseResponse> SaveMember(MemberRequest memberRequest)
        {
            try
            {
                Member member = new Member();
                if (memberRequest != null)
                {
                    var minresult = await _dBContext.Physican.AsNoTracking().MinAsync(x => x.PhysicianId);

                    var maxresult = await _dBContext.Physican.AsNoTracking().MaxAsync(x => x.PhysicianId);

                    Random random            = new Random();
                    int    randomPhysicianId = random.Next(minresult, maxresult);
                    //member.PhysicianId = randomPhysicianId;

                    member = new Member()
                    {
                        MemberID     = 0,
                        FirstName    = memberRequest.FirstName,
                        LastName     = memberRequest.LastName,
                        EmailAddress = memberRequest.EmailAddress,
                        Address      = memberRequest.Address,
                        SSN          = memberRequest.SSN,
                        State        = memberRequest.State,
                        PhysicianId  = randomPhysicianId
                    };

                    _dBContext.Member.Add(member);
                    await _dBContext.SaveChangesAsync();
                }
                return(new BaseResponse()
                {
                    StatusCode = StatusCodes.Status201Created,
                    StatusDescription = " Member Details Added Successfully! ",
                    ID = member.MemberID
                });
            }
            catch (Exception ex)
            {
                Log.Error("Exception occurred on Save Member", ex);
                return(new BaseResponse {
                    StatusCode = StatusCodes.Status500InternalServerError, StatusDescription = "Internal Server Error"
                });
            }
        }
Example #3
0
        public async Task <BaseResponse> SaveClaims(ClaimsRequest claimsRequest)
        {
            try
            {
                Claims     claims    = new Claims();
                ClaimTypes claimType = await _dBContext.ClaimTypes.AsNoTracking().Where(c => c.ClaimType == claimsRequest.ClaimType).FirstOrDefaultAsync();

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

                //var claim = await _dBContext.Claims.AsNoTracking().Where(c => c.ClaimID == claimDetail.ClaimID).FirstOrDefaultAsync();
                if (claimsRequest != null)
                {
                    claims = new Claims()
                    {
                        ClaimID     = 0,
                        ClaimType   = claimType.ClaimTypeID,
                        ClaimAmount = claimsRequest.ClaimAmount,
                        ClaimDate   = claimsRequest.ClaimDate,
                        Remarks     = claimsRequest.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
                });
            }
            catch (Exception ex)
            {
                Log.Error("Exception occurred on Save Claims", ex);
                return(new BaseResponse {
                    StatusCode = StatusCodes.Status500InternalServerError, StatusDescription = "Internal Server Error"
                });
            }
        }