protected RemarkState(string state, RemarkUser user,
                       string description = null, Location location  = null,
                       RemarkPhoto photo  = null, DateTime?createdAt = null)
 {
     if (state.Empty())
     {
         throw new ArgumentException("State can not be empty.", nameof(state));
     }
     if (user == null)
     {
         throw new ArgumentException("User can not be null.", nameof(user));
     }
     if (description?.Length > 2000)
     {
         throw new ArgumentException("Description can not have more than 2000 characters.",
                                     nameof(description));
     }
     Id          = Guid.NewGuid();
     State       = state;
     User        = user;
     Description = description?.Trim() ?? string.Empty;
     Location    = location;
     Photo       = photo;
     CreatedAt   = createdAt.HasValue ? createdAt.Value : DateTime.UtcNow;
 }
 protected RemarkPhoto(Guid groupId, string name, string size, string url, RemarkUser user, string metadata,
                       bool validate = true)
 {
     if (groupId == Guid.Empty)
     {
         throw new ArgumentException("Photo id can not be empty.", nameof(groupId));
     }
     if (name.Empty())
     {
         throw new ArgumentException("Photo name can not be empty.", nameof(size));
     }
     if (validate && size.Empty())
     {
         throw new ArgumentException("Photo size can not be empty.", nameof(size));
     }
     if (validate && url.Empty())
     {
         throw new ArgumentException("Photo Url can not be empty.", nameof(url));
     }
     if (user == null)
     {
         throw new ArgumentException("Photo user can not be empty.", nameof(user));
     }
     GroupId   = groupId;
     Name      = name;
     Size      = size;
     Url       = url;
     User      = user;
     Metadata  = metadata;
     CreatedAt = DateTime.UtcNow;
 }
 private void SetUser(User user)
 {
     if (user == null)
     {
         throw new DomainException(OperationCodes.CommentUserNotProvided,
                                   $"Comment: '{Id}' user can not be null.");
     }
     User = RemarkUser.Create(user);
 }
Example #4
0
 public void SetAuthor(User author)
 {
     if (author == null)
     {
         throw new DomainException(OperationCodes.RemarkAuthorNotProvided,
                                   "Remark author can not be null.");
     }
     Author    = RemarkUser.Create(author);
     UpdatedAt = DateTime.UtcNow;
 }
Example #5
0
 protected Participant(User user, string description)
 {
     if (user == null)
     {
         throw new ArgumentException("User can not be null.", nameof(user));
     }
     if (description.Empty())
     {
         throw new ArgumentException("Description can not be empty.",
                                     nameof(description));
     }
     if (description.Length > 2000)
     {
         throw new ArgumentException("Description can not have more than 2000 characters.",
                                     nameof(description));
     }
     User        = RemarkUser.Create(user);
     Description = description.Trim();
     CreatedAt   = DateTime.UtcNow;
 }
Example #6
0
 public void SetCanceledState(User user, string description = null)
 => SetState(RemarkState.Canceled(RemarkUser.Create(user), description));
Example #7
0
 public void SetRenewedState(User user, string description = null,
                             RemarkPhoto photo             = null)
 => SetState(RemarkState.Renewed(RemarkUser.Create(user), description, photo));
Example #8
0
 public void SetProcessingState(User user, string description = null,
                                RemarkPhoto photo             = null)
 => SetState(RemarkState.Processing(RemarkUser.Create(user), description, photo));
 public static RemarkPhoto Create(Guid groupId, string name, string size, string url,
                                  RemarkUser user, string metadata = null)
 => new RemarkPhoto(groupId, name, size, url, user, metadata);
 public static RemarkPhoto AsProcessing(Guid groupId, RemarkUser user)
 => new RemarkPhoto(groupId, $"processing-{Guid.NewGuid()}", null, null, user, "processing", validate: false);
 public static RemarkPhoto Big(Guid groupId, string name, string url,
                               RemarkUser user, string metadata = null)
 => new RemarkPhoto(groupId, name, "big", url, user, metadata);
 public static RemarkState Resolved(RemarkUser user,
                                    string description = null, Location location = null, RemarkPhoto photo = null)
 => new RemarkState(Names.Resolved, user, description, location, photo);
 public static RemarkState Processing(RemarkUser user,
                                      string description = null, RemarkPhoto photo = null)
 => new RemarkState(Names.Processing, user, description, photo: photo);
 public static RemarkState New(RemarkUser user, Location location,
                               string description = null, DateTime?createdAt = null)
 => new RemarkState(Names.New, user, description, location, createdAt: createdAt);
 public static RemarkState Canceled(RemarkUser user, string description = null)
 => new RemarkState(Names.Canceled, user, description);