Represents an annotation for a photo.
예제 #1
0
        /// <summary>
        /// Reports the Annotation as inappropriate.
        /// </summary>
        /// <param name="annotation">The annotation to report.</param>
        public async Task ReportAnnotation(Annotation annotation)
        {
            try
            {
                var reportContract = new ReportContract
                {
                    ReportReason = ReportReason.Inappropriate,
                    ContentId = annotation.Id,
                    ContentType = ContentType.Annotation
                };

                await _mobileServiceClient.InvokeApiAsync<ReportContract, ReportContract>("report",
                    reportContract,
                    HttpMethod.Post,
                    null);
            }
            catch (Exception e)
            {
                throw new ServiceException("ReportAnnotation error", e);
            }
        }
예제 #2
0
 /// <summary>
 /// Removes the Annotation.
 /// </summary>
 /// <param name="annotation">The Annotation.</param>
 public async Task RemoveAnnotation(Annotation annotation)
 {
     try
     {
         await _mobileServiceClient.InvokeApiAsync($"annotation/{annotation.Id}",
             HttpMethod.Delete,
             null);
     }
     catch (Exception e)
     {
         throw new ServiceException("RemoveAnnotation error", e);
     }
 }
 /// <summary>
 /// Reports the Annotation as inappropriate.
 /// </summary>
 /// <param name="annotation">The Annotation.</param>
 public async Task ReportAnnotation(Annotation annotation)
 {
     await SimulateWaitAndError();
 }
        /// <summary>
        /// Removes the Annotation.
        /// </summary>
        /// <param name="annotation">The Annotation.</param>
        public async Task RemoveAnnotation(Annotation annotation)
        {
            await SimulateWaitAndError();

            var commentFromList = Annotations.SingleOrDefault(c => c.Id.Equals(annotation.Id));
            if (commentFromList != null)
            {
                Annotations.Remove(commentFromList);
            }
        }
        /// <summary>
        /// Posts the annotation.
        /// </summary>
        /// <param name="photo">The photo.</param>
        /// <param name="annotationText">The text.</param>
        /// <param name="goldCount">The amount of gold being given.</param>
        /// <returns>The annotation including the id.</returns>
        public async Task<Annotation> PostAnnotation(Photo photo, string annotationText, int goldCount)
        {
            await SimulateWaitAndError();

            var annotation = new Annotation
            {
                CreatedTime = DateTime.Now,
                Id = Guid.NewGuid().ToString(),
                Text = annotationText,
                From = AppEnvironment.Instance.CurrentUser,
                GoldCount = goldCount
            };

            Annotations.Add(annotation);
            photo.NumberOfAnnotations++;
            photo.GoldCount += annotation.GoldCount;

            if (AppEnvironment.Instance.CurrentUser != null)
            {
                AppEnvironment.Instance.CurrentUser.GoldBalance -= annotation.GoldCount;
            }

            return annotation;
        }
        private void InitAnnotations()
        {
            Annotations = new List<Annotation>();

            var comment = new Annotation
            {
                CreatedTime = DateTime.Now.AddMinutes(-2),
                From = new User
                {
                    ProfilePictureUrl = "https://canaryappstorage.blob.core.windows.net/dummy-container/a2_tn.jpg"
                },
                Text = "I love it!",
                Id = Guid.NewGuid().ToString(),
                GoldCount = 1
            };
            Annotations.Add(comment);

            var secondComment = new Annotation
            {
                CreatedTime = DateTime.Now.AddHours(-1),
                From = new User
                {
                    ProfilePictureUrl = "https://canaryappstorage.blob.core.windows.net/dummy-container/a7_tn.jpg"
                },
                Text = "Wow! :-)",
                Id = Guid.NewGuid().ToString(),
                GoldCount = 1
            };
            Annotations.Add(secondComment);
        }