Пример #1
0
        public void DeleteInsurance_With_InsuranceTO_Parameter()
        {
            //ARRANGE
            var options = new DbContextOptionsBuilder <FleetManagmentContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using var context = new FleetManagmentContext(options);

            IInsuranceRepository insuranceRepository = new InsuranceRepository(context);

            InsuranceTO insurance = new InsuranceTO
            {
                Name = "AG",
            };

            InsuranceTO insurance2 = new InsuranceTO
            {
                Name = "Ethias",
            };

            var addedInsurance  = insuranceRepository.Insert(insurance);
            var addedInsurance2 = insuranceRepository.Insert(insurance2);

            context.SaveChanges();

            //List<InsuranceTO> insurances = new List<InsuranceTO>();
            var insurances = insuranceRepository.GetAll().ToList();

            //ACT
            insuranceRepository.Remove(addedInsurance);
            context.SaveChanges();
            insurances = insuranceRepository.GetAll().ToList();

            //ASSERT
            Assert.IsNotNull(addedInsurance);
            Assert.IsNotNull(addedInsurance2);
            Assert.AreNotEqual(0, addedInsurance.Id);
            Assert.AreNotEqual(0, addedInsurance2.Id);
            Assert.AreEqual("AG", addedInsurance.Name);
            Assert.AreEqual("Ethias", addedInsurance2.Name);
            Assert.AreEqual(1, insurances.Count);
        }
        public ActionResult Insurance()
        {
            var user = _userService.GetCurrent();

            var models = _insuranceRepository
                         .GetAll()
                         .Where(x => x.Owner.Id == user.Id)
                         .Select(insurance =>
                                 _mapper.Map <InsurancePrintViewModel>(insurance)
                                 )
                         .ToList();

            return(View(models));
        }
Пример #3
0
 public List <Insurance> GetAll()
 {
     return(repository.GetAll(db).ToList());
 }
        public IHttpActionResult GetAllInsurance()
        {
            var insurance = repo.GetAll();

            return(Ok(insurance));
        }