Ejemplo n.º 1
0
        public async Task <ActionResult <ICollection <OwnerType> > > Search([FromQuery] SearchQueryOwnerType query)
        {
            var mapQuery     = _mapper.Map <SearchQueryOwnerType, Domain.Entities.SearchQueryOwnerType>(query);
            var queryResults = await _ownerTypeService.Search(mapQuery);

            var queryResultsContract = _mapper.Map <ICollection <OwnerType> >(queryResults);

            return(Ok(queryResultsContract));
        }
        private async Task <Dashboard> SetOwnerTypeDefault(Dashboard dashboardResource)
        {
            if (!dashboardResource.OwnerTypeId.HasValue)
            {
                var ownerTypeResult = await _ownerTypeService.Search(new Domain.Entities.SearchQueryOwnerType
                {
                    Name = "User",
                    Take = 1
                });

                var userOwnerType = ownerTypeResult.First();
                dashboardResource.OwnerTypeId = userOwnerType.Id;

                var userContext = _currentUserContext.Get();
                dashboardResource.OwnerId = userContext.UserId;
            }

            return(dashboardResource);
        }