示例#1
0
        public async Task <ActionResult <ActivityDto> > Details(Guid Id)
        {
            var details = new Details.Query();

            details.Id = Id;
            return(await Mediator.Send(details));
        }
示例#2
0
        public async Task <ActivityDto> Single([FromRoute] Details.Query query)
        {
            var         cacheKey = query.Id.ToString();
            ActivityDto activity;
            string      serializedActivity;

            var encodedActivity = await _cache.GetAsync(cacheKey);

            if (encodedActivity != null)
            {
                serializedActivity = Encoding.UTF8.GetString(encodedActivity);
                activity           = JsonSerializer.Deserialize <ActivityDto>(serializedActivity);
            }
            else
            {
                activity = await Mediator.Send(query);

                serializedActivity = JsonSerializer.Serialize(activity);
                encodedActivity    = Encoding.UTF8.GetBytes(serializedActivity);
                var option = new DistributedCacheEntryOptions()
                             .SetSlidingExpiration(TimeSpan.FromMinutes(2))
                             .SetAbsoluteExpiration(DateTimeOffset.Now.AddHours(1));
                await _cache.SetAsync(cacheKey, encodedActivity, option);
            }

            return(activity);
        }
示例#3
0
        public async Task <ActionResult <Activity> > Details(Guid id)
        {
            var query = new Details.Query()
            {
                Id = id
            };

            return(await _mediator.Send(query));
        }
示例#4
0
        public async Task <IActionResult> GetActivity(Guid id)
        {
            var detailsQuery = new Details.Query
            {
                Id = id
            };

            var result = await Mediator.Send(detailsQuery);

            return(HandleResult(result));
        }
示例#5
0
 public async Task <ActionResult <Profile> > Get([FromRoute] Details.Query query)
 {
     return(await Mediator.Send(query));
 }
示例#6
0
 public async Task <ActionResult <Activity> > Details(Guid id, Details.Query query)
 {
     query.Id = id;
     return(await _mediator.Send(query));
 }