public async Task Delete(ContractDTO dto)
        {
            var item = _context.Contracts.FirstOrDefault(o => o.Address == dto.Address && o.Country == dto.Country &&
                                                         o.DateOfBirth == dto.DateOfBirth && o.Gender == dto.Gender && o.SaleDate == dto.SaleDate && o.Name == dto.Name);

            if (item != null)
            {
                _context.Contracts.Remove(item);
                await _context.SaveChangesAsync();
            }
        }
        public async Task Update(ContractDTO dto)
        {
            var item = _context.Contracts.FirstOrDefault(o => o.Address == dto.Address && o.Country == dto.Country &&
                                                         o.DateOfBirth == dto.DateOfBirth && o.Gender == dto.Gender && o.SaleDate == dto.SaleDate && o.Name == dto.Name);

            if (item != null)
            {
                item.CoveragePlan = GetCoveragePlan(dto.Country, dto.SaleDate);
                item.NetPrice     = GetNetRate(dto.DateOfBirth, dto.Gender, item.CoveragePlan);
                await _context.SaveChangesAsync();
            }
        }
        public async Task Save(ContractDTO dto)
        {
            var contract = new ContractsModel
            {
                Address     = dto.Address,
                Country     = dto.Country,
                DateOfBirth = dto.DateOfBirth,
                Gender      = dto.Gender,
                SaleDate    = dto.SaleDate,
                Name        = dto.Name,
            };

            contract.CoveragePlan = GetCoveragePlan(dto.Country, dto.SaleDate);
            contract.NetPrice     = GetNetRate(dto.DateOfBirth, dto.Gender, contract.CoveragePlan);
            contract.Id           = _context.Contracts.Count() + 1;
            await _context.Contracts.AddAsync(contract);

            await _context.SaveChangesAsync();
        }
Exemplo n.º 4
0
 public async Task Delete(ContractDTO dto)
 {
     await _repository.Delete(dto);
 }
Exemplo n.º 5
0
 public Task Update(ContractDTO dto)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public async Task Save(ContractDTO dto)
 {
     await _repository.Save(dto);
 }