Ejemplo n.º 1
0
        // GET: Request/Details/5
        public ActionResult Details(int id)
        {
            ClientRequestForm request = sr.GetById((long)id);
            RequestModel      rm      = new RequestModel();

            rm.Description       = request.Description;
            rm.EndDate           = request.EndDate;
            rm.Fees              = request.Fees;
            rm.ProfileNeeded     = request.ProfileNeeded;
            rm.Type              = request.Type;
            rm.YearsOfExperience = request.YearsOfExperience;
            rm.IdProject         = request.IdProject;

            return(View(rm));
        }
        public async Task GetRequestByIdShouldReturnCorrectlyTest()
        {
            var dbContext = ApplicationDbContextInMemoryFactory.InitializeContext();

            MapperInitializer.InitializeMapper();

            var requestRepository             = new EfDeletableEntityRepository <Request>(dbContext);
            var hospitalDataRequestRepository = new EfDeletableEntityRepository <HospitalDataRequest>(dbContext);
            var hospitalDataRepository        = new EfDeletableEntityRepository <HospitalData>(dbContext);
            var recipientReques    = new EfDeletableEntityRepository <RecipientRequest>(dbContext);
            var locationRepository = new EfDeletableEntityRepository <Location>(dbContext);

            var service = new RequestsService(
                requestRepository,
                hospitalDataRequestRepository,
                hospitalDataRepository,
                recipientReques,
                locationRepository);

            await SeedDataAsync(dbContext);

            var request = requestRepository.All().FirstOrDefault();

            var result = service.GetById <RequestInfoViewModel>(request.Id);

            Assert.NotNull(result);
        }
        public void GetRequestByIdShouldThrowErrorTest()
        {
            var dbContext = ApplicationDbContextInMemoryFactory.InitializeContext();

            MapperInitializer.InitializeMapper();

            var requestRepository             = new EfDeletableEntityRepository <Request>(dbContext);
            var hospitalDataRequestRepository = new EfDeletableEntityRepository <HospitalDataRequest>(dbContext);
            var hospitalDataRepository        = new EfDeletableEntityRepository <HospitalData>(dbContext);
            var recipientReques    = new EfDeletableEntityRepository <RecipientRequest>(dbContext);
            var locationRepository = new EfDeletableEntityRepository <Location>(dbContext);

            var service = new RequestsService(
                requestRepository,
                hospitalDataRequestRepository,
                hospitalDataRepository,
                recipientReques,
                locationRepository);

            Assert.Throws <ArgumentException>(() => service.GetById <RequestInfoViewModel>(null));
        }