Exemplo n.º 1
0
        public async Task Delete(Claim claim)
        {
            var claimDB = claimMapper.Map(claim);

            if (claimDB.Adress != null)
            {
                claimDB.Adress.Province = null;
                claimDB.Adress.City     = null;
                applicationDbContext.Adresses.Remove(claimDB.Adress);
                applicationDbContext.SaveChanges();
            }
        }
        public async Task DeleteAll(Claim claim)
        {
            var claimDB = claimMapper.Map(claim);

            if (claimDB.ClaimThirdInsuredVehicles != null)
            {
                claimDB.ClaimThirdInsuredVehicles.ForEach(async vehicle =>
                {
                    await DeleteClaimVehicle(vehicle);
                });
            }
        }
Exemplo n.º 3
0
        public async Task DeleteAll(Claim claim)
        {
            var claimDB = claimMapper.Map(claim);

            if (claimDB.ClaimThirdInsuredPersons == null)
            {
                return;
            }

            claimDB.ClaimThirdInsuredPersons.ForEach(async claimThirdInsuredPerson =>
            {
                await DeleteClaimPerson(claimThirdInsuredPerson);
            });
        }
Exemplo n.º 4
0
        public async Task <long> Save(Claim claim, string userName)
        {
            long result = 0;

            using (var transaction = applicationDbContext.Database.BeginTransaction())
            {
                try
                {
                    var claimDb = claimMapper.Map(claim);

                    claimDb.StateModifiedDate = DateTime.Now;
                    claimDb.UserName          = userName;

                    applicationDbContext.Claims.Add(claimDb);
                    applicationDbContext.SaveChanges();

                    transaction.Commit();

                    result = claimDb.Id;
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw new ApplicationException(ex.Message);
                }
            }

            return(result);
        }
Exemplo n.º 5
0
        public async Task DeleteClaimFiles(Claim claim)
        {
            var claimDB = claimMapper.Map(claim);

            if (claimDB.Files != null)
            {
                claimDB.Files.ForEach(file =>
                {
                    applicationDbContext.ClaimFiles.Remove(file);
                    applicationDbContext.SaveChanges();
                });
            }
        }