示例#1
0
        public InsurancePlanBenefit AddBenefit(InsurancePlanBenefit item)
        {
            //var OptionalCover = _context.OptionalCover.Find(item.OptionalCoverId);

            if (!_context.Covers.Any(u => u.Id == item.CoverId))
            {
                throw new AppException("Insurance Plan not found");
            }

            if (!_context.InsuranceBenefitType.Any(r => r.Id == item.InsuranceBenefitTypeId && r.DeletedAt == null))
            {
                throw new AppException("Benefit Type not found");
            }

            if (_context.InsurancePlanBenefit.Any(r => r.CoverId == item.CoverId && r.InsuranceBenefitTypeId == item.InsuranceBenefitTypeId))
            {
                _context.InsurancePlanBenefit.Update(item);
                //throw new AppException("Optional Cover " + OptionalCover.Name  + " is already exists");
            }
            else
            {
                _context.InsurancePlanBenefit.Add(item);
            }


            _context.SaveChanges();

            return(item);
        }
示例#2
0
        public IActionResult AddBenefit([FromBody] InsurancePlanBenefit item)
        {
            try
            {
                //CoversOptionalCover CoversOptionalCover = new CoversOptionalCover
                //{
                //    CoverId  = CoverId,
                //    OptionalCoverId  = OptionalCoverId
                //};

                _itemService.AddBenefit(item);

                return(Ok(item));
            }
            catch (AppException ex)
            {
                return(DefaultError(ex.Message));
            }
        }