private async Task <DTOs.GridElment> ResolveGridElement(Mdls.Milestone milestone, string ownerId)
        {
            bool IsLiked = await likeRepository.HasLike(milestone.id, ownerId);

            DTOs.User user = await userCache.GetUser(milestone.UserId);

            Models.enums.LikeType Like = IsLiked ? Models.enums.LikeType.ON : Models.enums.LikeType.OFF;

            DTOs.GridElment ge = new DTOs.GridElment
            {
                Like      = Like,
                Milestone = milestone,
                User      = user,
                Self      = ownerId == milestone.UserId
            };
            return(ge);
        }
        public async Task <ActionResponse> Add([FromBody] Mdls.Milestone milestone)
        {
            milestone.UserId = currentAuthenticationContext.CurrentUser;

            string milestoneId = await milestoneRepository.Add(milestone);

            if (milestone.Image != null && milestone.Image.StartsWith("data:image/png;base64,"))
            {
                string path = await amazonS3ImageProvider.Add($"milestones/{milestone.UserId}/{milestoneId}/img.png", milestone.Image);

                bool saved = await milestoneRepository.SetImage(milestoneId, path);
            }

            return(new ActionResponse()
            {
                State = !String.IsNullOrEmpty(milestoneId)
            });
        }
        public async Task <DTOs.GridElment> GetRecord(string milestoneId)
        {
            Mdls.Milestone milestone = await milestoneRepository.Get(milestoneId);

            DTOs.User user = await userCache.GetUser(milestone.UserId);

            bool IsLiked = await likeRepository.HasLike(milestone.id, milestone.UserId);

            Models.enums.LikeType Like = IsLiked ? Models.enums.LikeType.ON : Models.enums.LikeType.OFF;

            return(new DTOs.GridElment
            {
                Milestone = milestone,
                User = user,
                Like = Like,
                Self = currentAuthenticationContext.CurrentUser == milestone.UserId
            });
        }
        public async Task <ActionResponse> RemoveItem(string milestoneId)
        {
            Mdls.Milestone milestone = await milestoneRepository.Get(milestoneId);

            if (milestone != null)
            {
                bool isOwner = milestone.UserId == currentAuthenticationContext.CurrentUser;
                if (isOwner)
                {
                    bool deleted = await milestoneRepository.Delete(milestoneId);

                    bool awsdeleted = await amazonS3ImageProvider.Delete($"milestones/{milestone.UserId}/{milestone.id}/img.png");

                    return(new ActionResponse
                    {
                        State = deleted
                    });
                }
            }

            return(new ActionResponse {
                State = false
            });
        }
        public async Task <Mdls.Milestone> Get(string id)
        {
            Mdls.Milestone milestone = await milestoneRepository.Get(id);

            return(milestone);
        }