Ejemplo n.º 1
0
        public virtual async Task <ActionResult <IEnumerable <TResource> > > GetAll()
        {
            var entities = await LookupRepository.Get();

            var response = await ResourceMapper.Map(entities);

            return(response.ToList());
        }
Ejemplo n.º 2
0
        public virtual async Task <ActionResult <IEnumerable <TResource> > > GetAllOwned()
        {
            var entities = await LookupRepository.FindAll(e => e.UserId == CurrentUser.Id);

            var response = await ResourceMapper.Map(entities);

            return(response.ToList());
        }
Ejemplo n.º 3
0
        public virtual async Task <ActionResult <IEnumerable <TResource> > > Query(QueryResource queryResource)
        {
            var queryRequest = QueryResourceMapper.Map <TResource>(queryResource);

            var validateResult = Validate(queryRequest);

            if (validateResult != null)
            {
                return(BadRequest((BadRequestReason)validateResult));
            }

            var entities = await QueryRepository.Query(queryRequest);

            var response = await ResourceMapper.Map(entities);

            return(response.ToList());
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <IEnumerable <TResource> > > BatchCreate(TAlterResource[] resources)
        {
            var validation = await ResourceValidator.ValidateCreate(resources);

            if (validation.Any())
            {
                return(GetValidationResult(validation));
            }

            var entitiesTasks = resources.Select(async resource => await Map(resource));
            var entities      = entitiesTasks.Select(er => er.Result).ToList();

            await AddEntites(entities);

            var response = await ResourceMapper.Map(entities);

            return(response.ToList());
        }
Ejemplo n.º 5
0
 public void Convert_EnumToIntBehavesCorrectly()
 {
     _resourceMapper.ConvertUsing((CustomEnum1 v) => (int)v);
     _resourceMapper.InitializeMap();
     Assert.AreEqual(1, _resourceMapper.Map <CustomEnum1, int>(CustomEnum1.Value2, null));
 }