aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services/Timeline/TimelinePostNotExistException.cs
blob: 87c190ab03a86aeb66c1bf58a336d898fcff00d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Globalization;

namespace Timeline.Services.Timeline
{
    [Serializable]
    public class TimelinePostNotExistException : EntityNotExistException
    {
        public TimelinePostNotExistException() : this(null, null, false, null, null) { }
        public TimelinePostNotExistException(string? message) : this(message, null) { }
        public TimelinePostNotExistException(string? message, Exception? inner) : this(null, null, false, message, inner) { }
        protected TimelinePostNotExistException(
          System.Runtime.Serialization.SerializationInfo info,
          System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
        public TimelinePostNotExistException(long? timelineId, long? postId, bool isDelete, string? message = null, Exception? inner = null)
            : base(EntityNames.TimelinePost, message ?? MakeMessage(isDelete), inner)
        {
            TimelineId = timelineId;
            PostId = postId;
            IsDelete = isDelete;
        }

        private static string MakeMessage(bool isDelete)
        {
            return string.Format(CultureInfo.CurrentCulture, Resource.ExceptionTimelinePostNoExist, isDelete ? Resource.ExceptionTimelinePostNoExistReasonDeleted : Resource.ExceptionTimelinePostNoExistReasonNotCreated);
        }

        public long? TimelineId { get; set; }
        public long? PostId { get; set; }

        /// <summary>
        /// True if the post is deleted. False if the post does not exist at all.
        /// </summary>
        public bool IsDelete { get; set; }
    }
}