public void AddComment(IComment commentToAdd, IVehicle vehicleToAddComment) { CustomValidator.ValidateNull(commentToAdd, Constants.CommentCannotBeNull); CustomValidator.ValidateNull(vehicleToAddComment, Constants.VehicleCannotBeNull); vehicleToAddComment.Comments.Add(commentToAdd); }
public void RemoveComment(IComment commentToRemove, IVehicle vehicleToRemoveComment) { CustomValidator.ValidateNull(commentToRemove, Constants.CommentCannotBeNull); CustomValidator.ValidateNull(vehicleToRemoveComment, Constants.VehicleCannotBeNull); if (commentToRemove.Author != this.Username) { throw new ArgumentException(Constants.YouAreNotTheAuthor); } vehicleToRemoveComment.Comments.Remove(commentToRemove); }
public void AddVehicle(IVehicle vehicle) { CustomValidator.ValidateNull(vehicle, Constants.VehicleCannotBeNull); if (this.Role == Role.Admin) { throw new ArgumentException(Constants.AdminCannotAddVehicles); } else if ((this.Role != Role.VIP) && (this.Vehicles.Count >= Constants.MaxVehiclesToAdd)) { throw new ArgumentException(string.Format(Constants.NotAnVipUserVehiclesAdd, Constants.MaxVehiclesToAdd)); } this.Vehicles.Add(vehicle); }
public Comment(string content) { CustomValidator.ValidateNull(content, Constants.CommentCannotBeNull); CustomValidator.ValidateStringRange(content, Constants.MinCommentLength, Constants.MaxCommentLength, Constants.NumberMustBeBetweenMinAndMax); this.Content = content; }
public void RemoveVehicle(IVehicle vehicle) { CustomValidator.ValidateNull(vehicle, Constants.VehicleCannotBeNull); this.Vehicles.Remove(vehicle); }