aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services/Exceptions/TimelinePostNotExistException.cs
blob: f95dd4106de7da48640f4efadabe8e3be35f9238 (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
using System;
using System.Globalization;

namespace Timeline.Services.Exceptions
{
    [Serializable]
    public class TimelinePostNotExistException : EntityNotExistException
    {
        public TimelinePostNotExistException() : this(null, null, false, null, null) { }
        [Obsolete("This has no meaning.")]
        public TimelinePostNotExistException(string? message) : this(message, null) { }
        [Obsolete("This has no meaning.")]
        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(string? timelineName, long? id, bool isDelete, string? message = null, Exception? inner = null) : base(EntityNames.TimelinePost, null, MakeMessage(timelineName, id, isDelete).AppendAdditionalMessage(message), inner) { TimelineName = timelineName; Id = id; IsDelete = isDelete; }

        private static string MakeMessage(string? timelineName, long? id, bool isDelete)
        {
            return string.Format(CultureInfo.InvariantCulture, isDelete ? Resources.Services.Exceptions.TimelinePostNotExistExceptionDeleted : Resources.Services.Exceptions.TimelinePostNotExistException, timelineName ?? "", id);
        }

        public string? TimelineName { get; set; }
        public long? Id { get; set; }

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