Beispiel #1
0
        public bool AddPolicy(PolicyModel policy)
        {
            var entity = new Policie()
            {
                PolicyNumber     = policy.PolicyNumber,
                CarId            = policy.CarId,
                EffectiveDate    = (DateTime)policy.EffectiveDate,
                EndDate          = (DateTime)policy?.EndDate,
                IsGroupInsurance = policy.IsGroupInsurance,
                IsActive         = true,
                AddUser          = LoginUserDetails.GetWindowsLoginUserName(),
                AddDate          = DateUtil.GetCurrentDate(),
                CoverageId       = policy.CoverageId,
                ProductId        = policy.ProductId
            };

            _policyRepository.Add(entity);

            var latestPolicy = _policyRepository.GetAll().OrderByDescending(p => p.Id).FirstOrDefault();

            if (latestPolicy != null)
            {
                var clientPolocieModel = new ClientPolicie()
                {
                    ClientId  = policy.ClientId,
                    PolicieId = latestPolicy.Id,
                    IsActive  = true,
                    AddUser   = LoginUserDetails.GetWindowsLoginUserName(),
                    AddDate   = DateUtil.GetCurrentDate()
                };
                _commonService.AddClientPolocie(clientPolocieModel);
            }

            return(true);
        }
Beispiel #2
0
        public bool Delete(int id)
        {
            var policy = new Policie()
            {
                Id = id
            };

            _hanysContext.Policies.Attach(policy);
            _hanysContext.Policies.Remove(policy);
            _hanysContext.SaveChanges();
            return(true);
        }
Beispiel #3
0
        public bool Update(Policie policy)
        {
            var data = _hanysContext.Policies.FirstOrDefault(c => c.Id == policy.Id);

            if (data != null)
            {
                data.IsActive         = policy.IsActive;
                data.CarId            = policy.CarId;
                data.CoverageId       = policy.CoverageId;
                data.ProductId        = policy.ProductId;
                data.PolicyNumber     = policy.PolicyNumber;
                data.EffectiveDate    = policy.EffectiveDate;
                data.EndDate          = policy?.EndDate;
                data.IsGroupInsurance = policy.IsGroupInsurance;
                data.RevDate          = policy.RevDate;
                data.RevUser          = policy.RevUser;
                _hanysContext.SaveChanges();
            }
            return(true);
        }
Beispiel #4
0
        public bool ModifyPolicy(PolicyModel policy)
        {
            var entity = new Policie()
            {
                Id               = policy.Id,
                PolicyNumber     = policy.PolicyNumber,
                IsActive         = policy.IsActive,
                CarId            = policy.CarId,
                CoverageId       = policy.CoverageId,
                ProductId        = policy.ProductId,
                EffectiveDate    = (DateTime)policy.EffectiveDate,
                EndDate          = policy.EndDate,
                IsGroupInsurance = policy.IsGroupInsurance,
                AddUser          = policy.AddUser,
                AddDate          = policy.AddDate,
                RevDate          = DateUtil.GetCurrentDate(),
                RevUser          = LoginUserDetails.GetWindowsLoginUserName()
            };

            return(_policyRepository.Update(entity));
        }
Beispiel #5
0
 public bool Add(Policie policy)
 {
     _hanysContext.Policies.Add(policy);
     _hanysContext.SaveChanges();
     return(true);
 }