Beispiel #1
0
        public Insurance Find([FromBody] InsuranceQueryModel query)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (query.ContractId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(query.ContractId));
            }

            var model = _insuranceRepository.Find(query);

            if (model == null)
            {
                var contract = _contractRepository.Get(query.ContractId);
                model = new Insurance
                {
                    ContractId      = query.ContractId,
                    Contract        = contract,
                    InsurancePeriod = 360,
                    BeginDate       = contract.ContractDate.AddDays(1),
                    BranchId        = _branchContext.Branch.Id,
                    UserId          = _sessionContext.UserId,
                    OwnerId         = _branchContext.Branch.Id
                };
            }

            return(model);
        }